anvil dev to start a local development server that watches your routes directory and reloads route handlers the moment you save a file. Route modules are loaded on-the-fly so you write plain TypeScript — no compilation step required before your changes are live.
Usage
Flags
Path to the directory Anvil scans for route files. Passed to the compiler’s manifest loader. Change this if your project uses a non-standard layout.
TCP port the HTTP server listens on. Useful when you need to run multiple Anvil apps side by side, or when port
3000 is already taken.Hostname to bind. Omit to bind to all interfaces (
0.0.0.0). Set to 127.0.0.1 to restrict the server to localhost only.How it works
When you runanvil dev, the following happens:
Scan and load routes
Anvil reads your routes directory, builds an in-memory manifest, and prints each discovered route with its HTTP method and URL pattern.
Start the HTTP server
An HTTP server starts listening on the configured port. The server is backed by a live reference to the current app instance.
Watch for file changes
Anvil watches the routes directory recursively. Any
add, change, or unlink event triggers a debounced reload (100 ms debounce to coalesce rapid saves).Example output
Example: custom port and routes directory
Each reload clears the module cache for the routes directory, ensuring edited files are always re-read from disk. Singletons shared across route files — such as a shared trace store — still resolve to one instance within a single build pass because the module cache is shared within that pass.