CLI Reference
Rex provides a command-line interface for development, building, and running your application.
rex init
Create a new Rex project.
rex init <name>Scaffolds a new project directory with a basic page, package.json, and tsconfig.json.
rex init my-app
cd my-app
npm install
rex devrex dev
Start the development server with hot module replacement (HMR).
rex dev [options]| Option | Description |
|---|---|
--port <port>, -p | Port to listen on (default: 3000) |
--host <addr>, -H | Host to bind to (default: 127.0.0.1) |
--root <path> | Project root directory (default: current directory) |
--no-tui | Disable TUI, use plain log output |
The dev server watches your files and automatically rebuilds when you make changes. HMR updates are pushed to the browser over a WebSocket connection — no full page reload needed for most changes.
rex dev --port 8080 --host 0.0.0.0rex build
Create a production build.
rex build [options]| Option | Description |
|---|---|
--root <path> | Project root directory |
This produces optimized bundles in .rex/build/:
- Server bundle — single IIFE for V8 SSR
- Client bundles — code-split ESM chunks
- Manifest — route map and build metadata
- CSS — extracted and optimized stylesheets
rex build && rex startrex start
Start the production server using a pre-built bundle.
rex start [options]| Option | Description |
|---|---|
--port <port>, -p | Port to listen on (default: 3000) |
--host <addr>, -H | Host to bind to (default: 0.0.0.0) |
--root <path> | Project root directory |
Requires rex build to have been run first. Static pages are pre-rendered at startup for zero-latency serving.
Note:
rex startdefaults to0.0.0.0(all interfaces) whilerex devdefaults to127.0.0.1(localhost only).
rex live
Start a live mode server that compiles and serves projects on-demand from source.
rex live [options]| Option | Description |
|---|---|
-m, --mount <prefix>=<path> | Mount a project at a URL prefix (repeatable) |
--port <port>, -p | Port to listen on (default: 4000) |
--host <addr>, -H | Host to bind to (default: 127.0.0.1) |
--workers <n> | V8 worker threads per project (default: 4) |
Projects are compiled on the first request and cached. Source file changes automatically invalidate the cache. Mount multiple projects under different prefixes:
rex live -m /=./my-app -m /admin=./admin-appSee Live Mode for details.
rex typecheck
Run the TypeScript compiler to check for type errors.
rex typecheck [options] [-- <tsc args>]| Option | Description |
|---|---|
--root <path> | Project root directory |
Runs tsc --noEmit against your project. Additional arguments are passed through to tsc.
rex lint
Run the linter on your TypeScript and JavaScript files.
rex lint [options] [paths...]| Option | Description |
|---|---|
--root <path> | Project root directory |
--fix | Auto-fix fixable problems |
--deny-warnings | Treat warnings as errors |
Uses OxLint for fast, zero-config linting. No ESLint setup required. Optionally pass specific paths to lint.
rex fmt
Format your source files.
rex fmt [options]| Option | Description |
|---|---|
--root <path> | Project root directory |
--check | Check formatting without writing (exits with error if unformatted) |
Formats TypeScript, JavaScript, CSS, and JSON files.
Environment variables
| Variable | Description |
|---|---|
PORT | Override the default port (same as --port) |
HOST | Override the default host (same as --host) |
RUST_LOG | Set log level — e.g., RUST_LOG=rex=debug for verbose output |