CLI Commands
The Rejoice CLI helps you create, develop, and build projects.
Installation
cargo install rejoice
Commands
rejoice init
Create a new project.
# Create in a new directory
rejoice init my-app
# Create with database support
rejoice init my-app --with-db
# Initialize in current directory
cd my-empty-dir
rejoice init
Options:
| Option | Description |
|---|---|
[name] | Project name (optional, uses directory name if omitted) |
--with-db | Include SQLite database support |
What it creates:
Without --with-db:
- Basic Cargo.toml with Rejoice dependency
src/main.rswithApp::new()setupsrc/routes/layout.rsandsrc/routes/index.rsbuild.rsfor route generationclient/with Vite, Tailwind, and example SolidJS componentpackage.json,vite.config.ts,tsconfig.json
With --with-db:
- Everything above, plus:
.envwithDATABASE_URL- Empty
.dbSQLite file AppStatestruct with db poolApp::with_state()setup
rejoice dev
Start the development server.
rejoice dev
Features:
- Runs your app at
http://localhost:8080 - Watches Rust files and recompiles on changes
- Watches client files and rebuilds with Vite
- Live reload via WebSocket (
ws://localhost:3001/__reload) - Hot module replacement for islands
- Auto-generates boilerplate for new route and layout files
Auto-generated boilerplate:
When you create a new .rs file in src/routes/ while the dev server is running, it automatically populates the file with appropriate starter code:
- Route files get a
gethandler with the correct signature - Layout files get a layout function with
DOCTYPEand children - Dynamic routes like
[id].rsinclude the path parameter - If your app uses
AppState, the boilerplate includes it
When to restart manually:
- After adding new dependencies to
Cargo.toml - After modifying
build.rs
rejoice build
Build for production.
# Development build
rejoice build
# Production build (optimized)
rejoice build --release
Options:
| Option | Description |
|---|---|
--release | Build with optimizations |
Build steps:
- Install dependencies with Bun (if
node_modules/missing) - Generate islands registry
- Build client assets with Vite
- Compile Rust binary
Output:
| Asset | Location |
|---|---|
| Binary | target/debug/<name> or target/release/<name> |
| JavaScript | dist/islands.js |
| CSS | dist/styles.css |
rejoice migrate
Manage database migrations (requires --with-db project setup).
# Create a new migration
rejoice migrate add create_users_table
# Apply pending migrations
rejoice migrate up
# Revert the last migration
rejoice migrate revert
# Check migration status
rejoice migrate status
Subcommands:
| Command | Description |
|---|---|
add <name> | Create a new reversible migration (up.sql + down.sql) |
up | Apply all pending migrations |
revert | Revert the last applied migration |
status | Show which migrations have been applied |
Migrations are stored in the migrations/ directory. If sqlx-cli is not installed, the command will offer to install it automatically.
Environment
The CLI expects:
- Rust toolchain (cargo, rustc)
- Bun
- Project directory with
Cargo.toml
Next Steps
- Installation - Getting started
- Project Structure - Understanding the files
- Deployment - Running in production