brust 2.0.0-alpha.5
Guide / CLI

CLI

Three commands: build compiles the app into dist/, start serves it, dev rebuilds and reloads while you edit.

The commands

brust --help
usage:
  brust build [entry=routes.tsx] [--out-dir dist] [--force] [--target bun|cloudflare|static] [--actions-only] [--strict] [--wasm-from-source] [--dev]
  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]

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.

Live demoSwitchPanels · native

The pokedex example. Each React fallback prints once, with its rule and line.

$ brust build routes.tsx
warning hook-unsupported components/TeamBuilder.tsx:12:26 hook useReducer is not supported
warning hook-unsupported components/UnifiedIsland.tsx:11:25 hook useReducer is not supported
[brust] built dist in 73ms

brust build

  • Takes one entry, routes.tsx by default. A build error prints error <rule> <message> and exits 1.
  • Writes to a temporary folder and swaps it in only on success.
  • 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 cloudflare also writes dist/cf/, a Worker ready for wrangler.

brust start

  • Serves the built dist/; it takes no entry argument. It sets NODE_ENV=production unless you set it.
  • SIGINT or SIGTERM drain 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

FlagCommandsWhat it does
--out-dirbuild, dev (cloudflare)Where the build is written. Default dist.
--forcebuildWrites into an out dir that is not empty and was not made by brust.
--target bun|cloudflare|staticbuild, devbun 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).
--strictbuild --target staticA 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-onlybuildBuilds only the [actions] app, with no pages. It combines with --target bun (the default) and --target cloudflare. See Actions.
--devbuildAlso writes dev.json and builds the client runtime for dev. brust dev passes it for you; you rarely type it.
--wasm-from-sourcebuild, dev (cloudflare)Builds the Cloudflare wasm host from the repository's Rust source instead of using the published package.
--port, --workersstart, devThe port (0 picks a free one) and the number of Bun workers.
--dist-dir, --entrystartWhich built folder to serve and which routes module to load. Defaults dist and routes.tsx.
Note

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.