Dev server

crust dev owns the backend process. The frontend stays with its own dev server, so HMR is not crust's job and UI state survives a page edit.

crust dev

crust dev                          # current directory
crust dev --dir examples/dogear
crust dev --entry src/main.ts      # default: src/main.ts, then main.ts

What happens, in order:

stepbehaviour
configloads crust.config.ts or crust.json
frontendspawns dev.beforeDevCommand in the project directory, un-awaited, output inherited
dev URLwaits up to 30 s for dev.url to accept a TCP connection
runtimeruns the backend in a child process, because the platform's quit() calls process.exit
pagedev.url when set; otherwise the bridge serves public/index.html

The dev URL wait

The window loads dev.url exactly once, at creation, and cannot retry. On a cold start Vite needs 0.7–1.1 s to listen while the window appears at 0.2–0.4 s, so without the wait the page request went into a closed port and nothing ever rendered — 4 of 8 runs, and 4 of 4 from a directory with no pre-bundled dependencies. crust dev therefore probes the URL first and fails after 30 s rather than opening a window on a page that will never load.

The port

The bridge allows exactly the origin dev.url names, so pin the port (strictPort for Vite, -p for next dev); a dev server that picks a different port is a page whose calls are refused.

Dev tokens and window labels

Under crust dev, a page on the dev origin selects its bridge token with ?window=<label>: any page can name any configured label and receive that label's token, so per-label grants in dev are a preview, not a security boundary. What protects a shipped app is that a built document's token is bound to its window when the document is served; capabilities are open by default and only deny by default once you configure security. A low-grant dev page can read a higher label's token from a same-origin iframe of ?window=<label>. If that distinction must hold, test crust build output, not the dev server — see Permissions.

What restarts the backend

The watcher covers the backend entry's directory. On a dev.url project that directory holds your UI too, so frontend extensions are skipped — a restart rotates the bridge token and the page already open starts failing its calls.

saved fileeffect
.ts, .jsruntime restarts, bridge token rotates
.tsx, .jsx, .css, .scss, .sass, .less, .html, images, fontsnothing — the dev server owns HMR

.ts is not skipped because the backend entry is one. That is the one trap: a page module written as .ts restarts the backend on every save. Rename it .tsx, or move it under a skipped directory such as public/. crust doctor names any file in that position.

crust dev app.tsx

A positional ending in .tsx, .jsx, .ts, .js or .html runs that one file as an app: no crust.config.ts, no main.ts, one 900×700 window.

rulebehaviour
shapethe file must exist, and its directory must hold no crust.config.ts or crust.json; a config beside it means a project, and crust refuses
export default in the sourcetreated as a React component, mounted into #root with react-dom/client from the file's own directory
no default exportloaded for its side effects; the file renders the document itself
commandsinfo and echo only — there is no backend module to register more
securityone crust-security: line declares it, JSON on one line: // crust-security: {"csp":"…","microphone":"…"} in a module, <!-- crust-security: {…} --> in .html; a literal because the config is embedded as one, and validated like a project config (Network)
editrebuilds page.js, writes a reload marker, the page reloads; the runtime is never restarted

An .html entry

crust dev page.html      # the file is the document
crust build page.html    # dist/page.app

An .html file is the page itself: crust copies it verbatim to <dir>/.crust/single/index.html, or <dir>/dist/single/index.html in a build, and skips the bundler, so nothing in it is rewritten. Dev prints mode static html (rebuilt on every change), and a save copies the file again.

What crust does not add: no #root div, no <script> of its own, and no reload poller. The marker is still written, so a page reloads only if its own code fetches __crust_reload.txt. Files beside the entry are not copied, so a page that needs them should inline its CSS and script or reference files the app already serves. window.crust still arrives, because the bridge injects its bootstrap into the document it serves.

It deliberately lacks HMR (a save rebuilds the page), watching of imported modules and CSS, a config surface, a custom backend and type checking. Add crust.config.ts and main.ts when the app needs any of them.

crust doctor

crust doctor
crust doctor --dir my-app

One line per check in the order a failure actually happens: platform, Bun, config, macOS version, shim compiles, bridge, dev port, dev URL, backend entry, page-side .ts modules, window layer, known-fatal traps, assets, templates, bundle. It exits 1 and prints <n> checks failed; a clean project ends all checks passed, exit 0.

Three lines matter for dev:

line[fail] means
dev porta process holds the port and answers nothing, so a strictPort server cannot start
dev urlthe dev server is not running or is on another port
dev watch.ts page modules the watcher will treat as backend code; a note, not a failure