First app
crust init my-app --react
cd my-app
bun install
crust dev
Scaffold, install, dev. crust init writes into an empty directory and refuses anything else, naming the entries it found, so nothing of yours is overwritten.
Pick a scaffold
| you have | flag | what it makes |
|---|---|---|
| HTML and CSS, no bundler | none | seven files; the bridge serves public/ itself |
| React, or a Vite frontend | --react | Vite on :5173, dev.url, build.assets: "dist/web" |
| Svelte, or a Vite frontend | --svelte | Vite on :5173, dev.url, build.assets: "dist/web" |
| Vue, or a Vite frontend | --vue | Vite on :5173, dev.url, build.assets: "dist/web" |
| Solid, or a Vite frontend | --solid | Vite on :5173 with Solid 2, dev.url, build.assets: "dist/web" |
| Next.js, app router | --next | next dev on :3000, static export to out/ |
The flag is the whole difference. Plain is the default, and passing any two flags is refused before anything is written.
What you see
The plain scaffold, measured from an empty directory:
crust dev — /…/my-app/crust.config.ts
frontend served by the bridge (public/index.html, no dev server)
bridge http://127.0.0.1:49283
window open
greet hello crust (page call answered)
Every Vite scaffold, and --next, prints the dev-server URL instead of "served by the bridge", and crust dev starts that server through beforeDevCommand, then waits until it accepts a connection before creating the window.
--solid bundles Vite with Solid 2 rather than SolidStart: Solid 2 retired SolidStart, and dev.url wants one SPA on one origin.
What the window is
One NSWindow holding a WKWebView, created from the windows array in crust.config.ts. The page inside it is a normal web page; window.crust is the bridge's client, and a call reaches a handler in main.ts.
import { app } from "crust";
app.command("greet", ({ name }) => `hello ${name}`);
await app.run();
const text = await window.crust.invoke("greet", { name: "crust" });
Two arguments is an app command. A plugin command takes three: invoke("fs", "readTextFile", { path }).
How the pieces run
- The backend is Bun. It owns the app process; with the scaffold's
window-all-closedlistener, closing the window ends it. - A backend edit restarts that process. Under
dev.urlthe dev server owns frontend files, so a.tsxor.cssedit restarts nothing. - Without
dev.urlthe bridge servespublic/itself and injects its own client, so an edit shows on the next reload with no build step. - The bridge binds
127.0.0.1on a port derived fromapp.id, so the page origin — and itslocalStorage,IndexedDBand caches — is stable across launches.
Where to go next
- Project files — which file is what, and the config surface.
- Windows — a second window, and what "closed" means.
- Config — every key and its default.