Development Server
The pidgn server command (also available as pidgn s) starts a development server that builds and runs your application, then watches for changes and automatically restarts when source files are modified.
pidgn 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 pidgn project directory:
Terminal window cd my_app -
Start the development server:
Terminal window pidgn 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 pidgn 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 pidgn server -
Generate new code as needed:
Terminal window # In another terminal:pidgn gen controller Productspidgn gen model Product name:string price:float in_stock:booleanpidgn 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:
pidgn testThis invokes zig build test and reports the results.
Listing routes
Section titled “Listing routes”To see all routes defined in your application:
pidgn routesThis runs your app with the --routes flag, which prints a formatted table of all registered routes, their HTTP methods, and handler functions.
Live reload
Section titled “Live reload”For instant browser refresh during development, combine pidgn server with live reload. The dev server handles Zig rebuilds, while live reload pushes changes to the browser over a WebSocket.
If your project uses the asset pipeline, run pidgn assets watch in a separate terminal alongside the dev server so that CSS and JavaScript changes are also picked up:
# Terminal 1: Zig source rebuildspidgn server
# Terminal 2: asset rebuildspidgn assets watchNext 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
- Live Reload for automatic browser refresh
- Asset Pipeline for bundled and fingerprinted assets