CLI
Three commands: build compiles the app into dist/, start serves it, dev rebuilds and reloads while you edit.
The commands
usage:
brust build [entry=routes.tsx] [--out-dir dist] [--force] [--target bun|cloudflare|static] [--actions-only] [--strict] [--wasm-from-source] [--dev] [--update-tiers]
brust dev [entry=routes.tsx] [--port N] [--workers N] (Bun target: proxy + hot reload + inline TUI)
brust dev [entry=routes.tsx] --target cloudflare [--out-dir dist] [--port N] [--wasm-from-source] [-- <wrangler args>]
brust start [--port N] [--workers N] [--dist-dir dist] [--entry routes.tsx]
brust shadcn init [component ...] [--force] [--css <file>] [--base-color <name>] [--shadcn-version <x.y.z>]Exit codes: 0 on success, 1 for a build or boot error, 2 for a usage error.
What they print
Real output, from the pokedex example and from this site's own build.
The pokedex example. Each React fallback prints once, with its rule and line.
$ brust build routes.tsx
warning hook-unsupported components/TeamBuilder.tsx:12:3 hook useTransition is not supported
warning hook-unsupported components/UnifiedIsland.tsx:11:3 hook useTransition is not supported
[brust] built dist in 73msReady once every worker has booted. Server log lines trimmed.
$ brust start
[brust] listening on 127.0.0.1:1337 (io: hyper(tokio))
[brust] ready (10 workers)start needs a built dist/ (the absolute path in the message is shortened to ~ here).
$ brust start
[brust] run brust build first (~/pokedex/dist/manifest.json not found)Plain output (a pipe or CI), recorded on the blank template: one page edit, then a stylesheet edit.
$ brust dev routes.tsx --port 4873
[brust] dev server on http://127.0.0.1:4873 — [r]eload [o]pen [w]arnings [c]lear [q]uit
[brust] building http://127.0.0.1:4873 gen 0
[brust] ready http://127.0.0.1:4873 gen 1 (55ms)
[brust] building http://127.0.0.1:4873 gen 1 (55ms)
[brust] ready http://127.0.0.1:4873 gen 2 (46ms)
[brust] css public/app.css (no reload)brust build
- Takes one entry,
routes.tsxby default. A build error printserror <rule> <message>and exits 1. - Writes to a temporary folder and swaps it in only on success.
dist/jinja/holds one template per page and layout. A component placed inside a page is printed in that page’s template and gets no file of its own. SetBRUST_BUILD_ALL_TEMPLATES=1to also write every component’s template when you want to read what one compiles to; the server ignores the extra files.- Compiles the pages and layouts on up to 4 compiler threads (fewer when the machine has fewer cores or the app fewer route files). Each thread keeps its own copy of the modules it reads, so a build takes more memory than on one thread. Set
BRUST_COMPILE_THREADSto choose the number;BRUST_COMPILE_THREADS=1compiles on one thread and gives that memory back. The output is the same at any number. - Refuses an out dir that is not empty and was not made by brust, unless you pass
--force, and never writes to the app root, your home or a folder with sources (out-dir-unsafe). --target cloudflarealso writesdist/cf/, a Worker ready for wrangler.
The template of a page or layout in dist/jinja/ holds every component placed in it, and brust start parses each of them when it loads. When one is larger than 1 MB the build prints warning template <name> is <n> MB (<source>) and still succeeds: a template that large slows start-up and holds its memory. It usually comes from a component inlined at many call sites, a very large literal, or deep conditional nesting. A long chain of one operator (a && b && …, a || b || …, a ?? b ?? …) prints each operand a fixed number of times, so it does not cause it. Split the component, move the large data into a prop or a loader, or keep that component in React.
To fail the build instead of warning, set [build] template_max_bytes in brust.toml to the largest template you accept, in bytes (see Configuration). A build with a template over it stops with one template-size error that lists every such template, largest first, with its size and the file it came from; a template over the budget is reported by that error and not by the 1 MB warning. The budget applies to every template the build writes, so it also applies to the extra ones BRUST_BUILD_ALL_TEMPLATES=1 writes, which is a debugging aid. It works for every target. brust dev prints the same lines as warning template-size and keeps running. A build that fails publishes nothing: it is written beside the output directory and replaces it only when it has finished, so an existing dist/ stays as the last good build left it.
brust start
- Serves the built
dist/; it takes no entry argument. It setsNODE_ENV=productionunless you set it. SIGINTorSIGTERMdrain in-flight requests, then exit 0. A second signal exits at once.- If a worker dies, the server drains and exits 1. It does not respawn workers: run it under a supervisor that restarts the process.
brust dev
brust dev is the development server for the Bun target. It rebuilds when you save, boots the new build beside the old one and swaps it in, and shows build errors above the last good page. It takes an entry, --port and --workers. The whole loop, the terminal keys, the browser overlay and the dev trace are on the Dev mode page.
brust dev --target cloudflare builds, runs wrangler dev, watches the app and rebuilds on a change (no hot reload). A failed rebuild keeps the running Worker. Arguments after -- go to wrangler, and the Bun dev server refuses them.
Every flag
| Flag | Commands | What it does |
|---|---|---|
--out-dir | build, dev (cloudflare) | Where the build is written. Default dist. |
--force | build, shadcn init | build: writes into an out dir that is not empty and was not made by brust. shadcn init: replaces an existing components.json and runs the theme step again. |
--target bun|cloudflare|static | build, dev | bun is the default. cloudflare also writes dist/cf/, a Worker for wrangler. static also renders every page to files in dist/static/ that you can upload to Cloudflare Pages (see Deployment). |
--strict | build --target static | A loader that reads the request (headers, cookies, query) fails the build instead of rendering the page a visitor with none of those would see. |
--actions-only | build | Builds only the [actions] app, with no pages. It combines with --target bun (the default) and --target cloudflare. See Actions. |
--dev | build | Also writes dev.json and builds the client runtime for dev. brust dev passes it for you; you rarely type it. |
--update-tiers | build | Rewrites the [tiers] snapshot with this build’s tiers instead of failing on a component that got heavier, and prints each difference. The [tiers.max] rules still apply. Without a [tiers] snapshot it prints tiers: --update-tiers has no effect: no [tiers] snapshot is configured and changes nothing. See Rendering tiers. |
--wasm-from-source | build, dev (cloudflare) | Builds the Cloudflare wasm host from the repository's Rust source instead of using the published package. |
--port, --workers | start, dev | The port (0 picks a free one) and the number of Bun workers. |
--dist-dir, --entry | start | Which built folder to serve and which routes module to load. Defaults dist and routes.tsx. |
--css --base-color --shadcn-version | shadcn init | The Tailwind entry CSS (default: the one top-level app.css-style file that imports tailwindcss), the shadcn base colour (default neutral) and an exact shadcn CLI version (default: the one brust tests). See Set up shadcn/ui. |
A page-only build (pages that call actions on another origin) has no flag. It is what brust build does when brust.toml sets [actions] base_url and the project has no actions file.