Dev server
Stati’s development server pairs incremental builds with live reload so you can preview content changes instantly.
Start the server
Use the CLI to launch the dev server:
# Default
stati dev
# Custom port and host
stati dev --port 4000 --host 0.0.0.0
# Automatically open your browser
stati dev --open
The --port, --host and --open flags map directly to the options accepted by createDevServer in @stati/core and override dev.port, dev.host and dev.open from your config.
What happens on startup
When you start the server Stati:
- Invalidates the incremental cache by calling
invalidate()with no query, so every page renders again. - Runs a full build with the current configuration so the
dist/directory is ready to serve. - Boots an HTTP server (default
http://localhost:3000) and a WebSocket endpoint at/__wsfor live reload events. Whensite.baseUrlhas a path, the site is served under it (http://localhost:3000/docs/):/redirects there and other URLs outside it are a 404, while/__wsstays at the server’s root. See Deploying to a subfolder. - Begins watching the resolved content directory (default
site) and static assets directory (defaultpublic).
If --open is set, Stati attempts to launch your default browser using the open package.
Live reload and incremental builds
File watching is handled by chokidar with listeners for file additions, edits, and deletions. Whenever a change is detected Stati:
- Starts an incremental rebuild. Changes made while a rebuild runs are queued and rebuilt together when it finishes.
- Logs which file triggered the rebuild, for example
▸ site/blog/post.md rebuiltfollowed byDone in 95ms. - Once the rebuild succeeds, broadcasts a
reloadmessage over the WebSocket connection so connected browsers refresh automatically. A failed rebuild reloads nothing; see Browser feedback.
Template changes and cache invalidation
Each page’s cache entry records the templates it rendered and the template names it looked up, so a template change rebuilds only the pages it affects:
- A changed template rebuilds the pages that rendered it. A template no page renders rebuilds nothing, and the log says
No page uses it. - A new template rebuilds the pages whose recorded template names now find it, such as the pages of a section that gains its own
partials/header.eta, or pages whosestati.include.has()check now finds a file. - A deleted template rebuilds the pages that rendered it, and the pages whose template names now find a different file.
Pages whose cache entries predate this record are rebuilt in full once.
Markdown changes rebuild the edited page, plus the pages whose output depends on it: pages that read its collection when a field in collections.summaryFields (by default the title, description, tags and draft flag), its URL or its date changed, and pages that render the navigation when the edit changed it (a title or order, or a page added or removed). Deleting a page removes its HTML from the output directory.
Static assets
Static files inside public are part of the watch list. When assets change they are recopied into dist/ during the rebuild, so image and favicon updates appear on the next refresh. Images next to your Markdown files are watched too: changing one rebuilds the pages that show it.
Responsive images and Open Graph cards take time to encode, so the dev server skips them by default and shows images with their size and lazy loading only. Set images.dev: 'full' to generate them while you work. See Images.
Tailwind CSS integration
Stati includes built-in Tailwind CSS support for the development server. When you provide --tailwind-input and --tailwind-output flags, Stati automatically starts a Tailwind CSS watcher alongside the dev server:
stati dev --tailwind-input src/styles.css --tailwind-output dist/styles.css
How it works:
- Stati spawns a Tailwind CLI process in watch mode using the locally installed
tailwindcssexecutable fromnode_modules/.bin/. Tailwind CSS 4 and 3 both work. - Pages link the output under its path in
dist/, here/styles.css: Stati adds<link rel="stylesheet" href="/styles.css">before</head>unless the page links it already orcss.autoInjectisfalse. An output outsidedist/is still written, but Stati can’t link it, and the dev server says so when it starts. - By default, only errors are shown (quiet mode) to keep the console clean.
- Use
--tailwind-verboseto see all Tailwind output including “done in Xms” messages. - The watcher runs for as long as the dev server does, including when the dev server runs in a background or CI shell without a terminal.
- When you stop the dev server (
Ctrl+C), the Tailwind watcher is automatically stopped as well. It also exits when the dev server process is killed, so no watcher is left running. - If the watcher stops on its own, for example because Tailwind CSS 4 found an error in the stylesheet at startup, the dev server says so. Fix the error and restart
stati dev.
Requirements:
- You must have the
tailwindcsscommand installed locally in your project. Tailwind CSS 4, the version the scaffolder installs, ships it in@tailwindcss/cli:npm install -D tailwindcss @tailwindcss/cli. With Tailwind CSS 3,npm install -D tailwindcss@3includes it. - If Tailwind CSS or the input file is missing,
stati devprints an error and exits.
stati build takes the same two flags and runs Tailwind once after the last page renders, writing a stylesheet named after its content. See CSS.
Example with verbose output:
stati dev --tailwind-input src/styles.css --tailwind-output dist/styles.css --tailwind-verbose
Browser feedback
- Successful rebuilds simply reload the page.
- When a build error occurs, Stati serves an error overlay in place of the page you requested. See Error overlay for what it shows.
- A template that reads a
stati.*property that does not exist, such asstati.paegor a misspelled helper, fails with a “Did you mean …?” suggestion instead of renderingundefined. See Unknown template properties. - The overlay stays connected to the dev server. Fix the error and save, and the page reloads on the next successful rebuild. The header shows whether the connection is live, and Refresh (or
Ctrl+R/Cmd+R) reloads by hand.
Stopping the server
Press Ctrl+C (or send SIGINT/SIGTERM) to stop the server. Stati closes the WebSocket server, file watcher, and HTTP listener before exiting.
Troubleshooting
- Changes not showing up – Ensure the file is inside
siteorpublic(or your TypeScriptsrcDir, which esbuild watches). Other files, includingstati.config.*, are not watched: restart the server after editing the config. - Cache feels stale – Restart
stati dev: startup clears the cache and rebuilds every page. Don’t runstati build --cleanwhile the dev server runs, as it deletes the output and the cache the server is using. - Port already in use – Start the server on a different port with
stati dev --port 4001.