Skip to content

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.

Terminal window
zzz server

The server performs the following cycle:

  1. Runs zig build run to compile and start your application.
  2. Prints “Server running. Watching for changes…” when the build succeeds.
  3. When the process exits (due to a file change trigger or an error), it rebuilds and restarts.
  4. Press Ctrl+C to stop.
  1. Navigate to your zzz project directory:

    Terminal window
    cd my_app
  2. Start the development server:

    Terminal window
    zzz server
  3. Open http://127.0.0.1:4000 in your browser.

  4. Edit any .zig file under src/ — the server will rebuild and restart automatically.

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.

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:

Terminal window
zig build run -Denv=staging

A typical development session looks like this:

  1. Start the dev server:

    Terminal window
    zzz server
  2. Generate new code as needed:

    Terminal window
    # In another terminal:
    zzz gen controller Products
    zzz gen model Product name:string price:float in_stock:boolean
    zzz migrate
  3. Edit the generated files to add your application logic.

  4. The dev server detects the changes and rebuilds automatically.

  5. Test your endpoints in the browser or with curl:

    Terminal window
    curl http://127.0.0.1:4000/products

In a separate terminal, use the test command to run your project’s test suite at any time:

Terminal window
zzz test

This invokes zig build test and reports the results.

To see all routes defined in your application:

Terminal window
zzz routes

This runs your app with the --routes flag, which prints a formatted table of all registered routes, their HTTP methods, and handler functions.