Rust + Oxc + direct DOM
Preact authoring.
Compiler-level work.
This page was rendered to HTML, hydrated, and made interactive by the compiler itself. No VDOM runtime ships in the browser bundle.
Server HTML ready · hydration pending
Live compiled component
3 rowsKeyed rows, direct updates
Compiler x-ray
Authored TSX becomes direct DOM work
Both panes come from this build. The right side is the Rust compiler's emitted JavaScript—not a hand-written approximation.
Inputdemo/src/App.tsx
222 linesimport { signal, useComputed, useSignalEffect } from "@preact/signals";
import { useState } from "preact/hooks";
import { StatCard } from "./StatCard.tsx";
interface DemoRow {
id: number;
label: string;
}
interface DemoProps {
rows: DemoRow[];
compiled: {
excerpt: string;
full: string;
lines: number;
bytes: string;
};
stats: {
upstream: string;
compatibility: string;
bundle: string;
hydration: string;
targets: string;
};
source: string;
sourceLines: number;
nextId(): number;
onCommit(rows: number): void;
}
export function App({
rows: initialRows,
compiled,
stats,
source,
sourceLines,
nextId,
onCommit
}: DemoProps) {
const [count, setCount] = useState(0);
const rows = signal(initialRows);
const selected = signal(initialRows[0].id);
const showFullOutput = signal(false);
const rowCount = useComputed(() => rows.value.length);
const compiledOutput = useComputed(() =>
showFullOutput.value ? compiled.full : compiled.excerpt
);
const outputLabel = useComputed(() =>
showFullOutput.value ? "Show focused excerpts" : "Show full emitted module"
);
useSignalEffect(() => {
onCommit(rowCount.value);
});
return (
<main className="showcase">
<section className="hero">
<div className="eyebrow">Rust + Oxc + direct DOM</div>
<h1>Preact authoring.<br />Compiler-level work.</h1>
<p className="lede">
This page was rendered to HTML, hydrated, and made interactive by the
compiler itself. No VDOM runtime ships in the browser bundle.
</p>
<div className="hero-actions">
<button id="increment" className="primary" onClick={() => setCount(count + 1)}>
Hook updates: {count}
</button>
<span id="hydration-result" className="runtime-status">
Server HTML ready · hydration pending
</span>
</div>
</section>
<section className="stats" aria-label="Verified project statistics">
<StatCard
value={stats.upstream}
label="upstream cases"
detail="independently compiled"
/>
<StatCard
value={stats.compatibility}
label="attributed behaviors"
detail="exact pinned titles"
/>
<StatCard
value={stats.bundle}
label="browser bundle"
detail="Brotli compressed"
/>
<StatCard
value={stats.hydration}
label="hydration model"
detail="shared template shape"
/>
</section>
<section className="demo-grid">
<article className="interactive-panel">
<div className="section-heading">
<div>
<span className="section-kicker">Live compiled component</span>
<h2>Keyed rows, direct updates</h2>
</div>
<strong className="row-count">{rowCount.value} rows</strong>
</div>
<div className="toolbar">
<button
id="add-row"
onClick={() =>
rows.value = rows.value.concat({
id: nextId(),
label: `Compiled row ${rows.value.length + 1}`
})
}
>
Add row
</button>
<button
id="rotate-rows"
onClick={() =>
rows.value = rows.value.length > 1
? rows.value.slice(1).concat(rows.value[0])
: rows.value
}
>
Rotate identity
</button>
</div>
<ul id="compiled-rows" className="compiled-rows">
{rows.value.map(row => (
<li
key={row.id}
data-id={row.id}
className={selected.value === row.id ? "selected" : ""}
>
<button
className="row-select"
onClick={() => selected.value = row.id}
>
<span>{row.label}</span>
<small>key {row.id}</small>
</button>
<button
className="row-remove"
aria-label={`Remove ${row.label}`}
onClick={() =>
rows.value = rows.value.filter(item => item.id !== row.id)
}
>
×
</button>
</li>
))}
</ul>
</article>
<aside className="proof-panel">
<span className="section-kicker">What this proves</span>
<h2>One authored component, three real paths</h2>
<ol>
<li><strong>Compile</strong><span>Oxc lowers TSX into direct DOM instructions.</span></li>
<li><strong>Render</strong><span>The same create path emits the server HTML you loaded.</span></li>
<li><strong>Hydrate</strong><span>Existing nodes are claimed before exact bindings attach.</span></li>
</ol>
<div className="target-row">
<span>Targets</span>
<code>{stats.targets}</code>
</div>
</aside>
</section>
<section className="compiler-panel">
<div className="compiler-heading">
<div>
<span className="section-kicker">Compiler x-ray</span>
<h2>Authored TSX becomes direct DOM work</h2>
</div>
<p>
Both panes come from this build. The right side is the Rust compiler's
emitted JavaScript—not a hand-written approximation.
</p>
</div>
<div className="compiler-flow">
<article className="code-card">
<header>
<div>
<span>Input</span>
<strong>demo/src/App.tsx</strong>
</div>
<small>{sourceLines} lines</small>
</header>
<pre><code>{source}</code></pre>
</article>
<div className="compile-arrow" aria-hidden="true">→</div>
<article className="code-card emitted-code">
<header>
<div>
<span>Rust / Oxc output</span>
<strong>App.compiled.mjs</strong>
</div>
<small>{compiled.lines} lines · {compiled.bytes}</small>
</header>
<pre id="compiled-output"><code>{compiledOutput.value}</code></pre>
<button
id="toggle-compiled-output"
className="output-toggle"
onClick={() => showFullOutput.value = !showFullOutput.value}
>
{outputLabel.value}
</button>
</article>
</div>
</section>
</main>
);
}
Rust / Oxc outputApp.compiled.mjs
1025 lines · 46,913 B// Generated by preact_compiler_lab. Do not edit by hand.
import { createRuntime, own as $own } from "preact-compiler-lab:runtime";
import { bindKeyedAttribute as $bindKeyedAttribute } from "preact-compiler-lab:runtime/keyed-attributes";
import { createComponent as $factory_StatCard, componentMetadata as $metadata_StatCard } from "./StatCard.compiled.mjs";
// … source-location table omitted from this focused view …
function $createRoot($ctx, $componentProps, $n = 0) {
return $ctx.renderPhase(() => {
let initialRows, compiled, stats, source, sourceLines, nextId, onCommit;
const $propsVersion0 = $ctx.signal(0);
$ctx.observe(() => { ({
rows: initialRows,
compiled,
stats,
source,
sourceLines,
nextId,
onCommit
} = $componentProps); $propsVersion0.value = $propsVersion0.peek() + 1; });
const {useState,signal,computed,effect,batch,useComputed,useSignalEffect}=$ctx;
const $state_count = useState(0);
let count = $state_count.value;
const setCount = value => { const $next_count = typeof value === "function" ? value($state_count.value) : value; $ctx.setState($state_count, $next_count, v=>count=v); };
const rows = signal(initialRows);
const selected = signal(initialRows[0].id);
const showFullOutput = signal(false);
const rowCount = useComputed(() => rows.value.length);
const compiledOutput = useComputed(() =>
showFullOutput.value ? compiled.full : compiled.excerpt
);
const outputLabel = useComputed(() =>
showFullOutput.value ? "Show focused excerpts" : "Show full emitted module"
);
useSignalEffect(() => {
onCommit(rowCount.value);
});
return () => {
const $el1 = $rt.element("main", $n);
$el1.setAttribute("class", "showcase");
const $el2 = $rt.element("section", $n);
$el2.setAttribute("class", "hero");
const $el3 = $rt.element("div", $n);
$el3.setAttribute("class", "eyebrow");
const $text4 = $rt.text("Rust + Oxc + direct DOM");
$el3.appendChild($text4);
$el2.appendChild($el3);
const $el5 = $rt.element("h1", $n);
const $text6 = $rt.text("Preact authoring.");
$el5.appendChild($text6);
// … direct instructions for the remaining static sections …
const $map47 = $rt.map($ctx, () => (rows.value), (row, $index, $ctx, $item48, $key) => {
const $el50 = $rt.element("li", $n);
$keyed49($ctx, $el50, $key);
const $el51 = $rt.element("button", $n);
$el51.setAttribute("class", "row-select");
$rt.bindEvent($ctx, $el51, "onClick", (() => selected.value = $item48.value.id));
const $el52 = $rt.element("span", $n);
const $text53 = $rt.text("");
$el52.appendChild($text53);
$el51.appendChild($el52);
const $el54 = $rt.element("small", $n);
const $text55 = $rt.text("key ");
$el54.appendChild($text55);
const $text56 = $rt.text("");
$el54.appendChild($text56);
$el51.appendChild($el54);
$el50.appendChild($el51);
const $el57 = $rt.element("button", $n);
$el57.setAttribute("class", "row-remove");
$rt.boundAttr($ctx, $el57, "aria-label", () => (`Remove ${row.label}`));
$rt.bindEvent($ctx, $el57, "onClick", (() =>
rows.value = rows.value.filter(item => item.id !== row.id)));
const $text58 = $rt.text("×");
$el57.appendChild($text58);
$el50.appendChild($el57);
let $value59, $value60, $value61;
$ctx.observe(() => {
let $error, $next;
if ($value59 !== $ctx) try {
$next = $rt.value($item48.value.id);
if ($next !== $value59) { $value59 = $next; $rt.setAttr($el50, "data-id", $next); }
} catch ($caught) { $value59 = $ctx; $error ??= $caught; }
if ($value60 !== $ctx) try {
$next = $rt.textValue($item48.value.label);
if ($next !== $value60) { $value60 = $next; if ($text53.data !== $next) $text53.data = $next; }
// … remaining keyed-row bindings omitted …
export function createApp(host = document, { hydratable = true } = {}) {
const $module = $createModule(host);
const $rt = $module.runtime;
return {
render(container, props = {}) {
const $ctx = $rt.createContext(props, true, hydratable);
const $value = $own($ctx, () => $module.create($ctx, props, $rt.ns(container)));
container.textContent = "";
const $root = $rt.mount(container, $value);
$own($ctx, () => $ctx.commit());
return { root: $root, dispose: () => $ctx.dispose() };
},
renderToString(props = {}) {
const $container = host.createElement("div");
const $ctx = $rt.createContext(props, false);
try {
const $value = $module.create($ctx, props);
$rt.mount($container, $value);
// … renderToString() and hydrate() share the generated template shape …