Development Server
The zzz server command (also available as zzz s) starts a development server that builds and runs your application, then watches for changes and automatically restarts when source files are modified.
zzz serverThe server performs the following cycle:
- Runs
zig build runto compile and start your application. - Prints “Server running. Watching for changes…” when the build succeeds.
- When the process exits (due to a file change trigger or an error), it rebuilds and restarts.
- Press
Ctrl+Cto stop.
Getting started
Section titled “Getting started”-
Navigate to your zzz project directory:
Terminal window cd my_app -
Start the development server:
Terminal window zzz server -
Open
http://127.0.0.1:4000in your browser. -
Edit any
.zigfile undersrc/— the server will rebuild and restart automatically.
Typical output
Section titled “Typical output”Starting zzz development server... Building... Server running. Watching for changes... (Ctrl+C to stop)If the build fails or the server exits with a non-zero code, the CLI waits two seconds before retrying:
Server exited with code 1. Waiting for changes to retry... Building...A clean exit (code 0) or a termination signal (e.g., Ctrl+C) stops the loop entirely.
Environment selection
Section titled “Environment selection”The dev server uses zig build run, which loads config/dev.zig by default. To run with a different environment configuration, use zig build run directly with the -Denv flag:
zig build run -Denv=stagingDevelopment workflow
Section titled “Development workflow”A typical development session looks like this:
-
Start the dev server:
Terminal window zzz server -
Generate new code as needed:
Terminal window # In another terminal:zzz gen controller Productszzz gen model Product name:string price:float in_stock:booleanzzz migrate -
Edit the generated files to add your application logic.
-
The dev server detects the changes and rebuilds automatically.
-
Test your endpoints in the browser or with
curl:Terminal window curl http://127.0.0.1:4000/products
Running tests alongside the server
Section titled “Running tests alongside the server”In a separate terminal, use the test command to run your project’s test suite at any time:
zzz testThis invokes zig build test and reports the results.
Listing routes
Section titled “Listing routes”To see all routes defined in your application:
zzz routesThis runs your app with the --routes flag, which prints a formatted table of all registered routes, their HTTP methods, and handler functions.
Next steps
Section titled “Next steps”- CLI overview for the full list of commands
- Create a new project if you have not set one up yet
- Generate code to add controllers, models, and channels
- Run migrations after generating models