- You are inside this repo
- Bun installed
- Rust toolchain installed (
cargoavailable) - You are building a demo app under
examples/
bun install
bun run build-ffiWhat this does: compiles core/ with cargo build --release.
Create a demo file under examples/:
import { Column, Text, $, ff, onKey, run } from "../index.ts";
const THEME = {
fg: 0xf5f7fa,
muted: 0x94a0b2,
positive: 0x5eff6c,
surface: 0x16181a,
border: 0x3c4048,
} as const;
const count = $(0);
const countText = Text({
text: "count: 0",
foreground: THEME.positive,
});
ff(() => {
countText.setText(`count: ${count()}`);
});
const root = Column(
{
flexGrow: 1,
padding: "1 1",
gap: 1,
background: THEME.surface,
border: { color: THEME.border, style: "rounded" },
},
[
Text({ text: "letui demo", foreground: THEME.fg }),
countText,
Text({
text: "+/- update, r reset, q quit",
foreground: THEME.muted,
}),
Text({
text: "starter uses gap/padding/flexGrow; wider layout API lives in StyleProps + BoxProps",
foreground: THEME.muted,
}),
],
);
const app = run(root);
onKey("+", () => count(count() + 1));
onKey("-", () => count(count() - 1));
onKey("r", () => count(0));
onKey("q", () => app.quit());bun run examples/<your-file>.ts+increment-decrementrresetqquit (custom handler)Ctrl+Qquit (default runtime handler)
- Replace static text with
Input+Button - Split UI into small builder functions (
buildHeader,buildBody,buildFooter) - Turn on metrics with
run(root, { debug: true })
- In
examples/, relative import from../index.tsis simplest starter path - Existing examples also use
@/...alias for modules insidesrc/ - Current public props come from
StyleProps,BoxProps,ScrollViewProps,TextProps,InputProps, andButtonPropsinsrc/types.ts - Keep node references stable across updates when you can; same-shape trees let runtime send deltas instead of rebuilding Rust tree state
run(root, { debug: true })prints phase timings on quit:js,render,sync,flush, plus worst-frame breakdown- To write those timings to a file, pass
run(root, { debug: true, metricsPath: "dump/metrics.txt" })