Dev Server

Cook includes a development server powered by BrowserSync. It builds your site, serves it locally, and automatically reloads the browser when you edit source files.

Start the server

This runs a full build, then starts a local server at http://localhost:3000 serving from dist/. The browser does not open automatically -- navigate to the URL yourself.

Live reload

Cook watches your src/ files for changes. When a file is saved:

  1. Cook runs a targeted rebuild for the changed file
  2. BrowserSync reloads the page in the browser

The default watch patterns cover the most common file types:

Add custom patterns in config/main.js:

By default, your paths are added in addition to the built-in patterns. Set watchReplace: true to replace them entirely.

Content negotiation

The dev server includes middleware that mirrors production routing (e.g. a Cloudflare Worker). It serves different responses based on request headers, so client-side tools work identically in development and production.

HeaderBehavior
X-Requested-With: htmlstarReturns _fragment.html instead of the full page
Accept: text/markdownReturns the markdown source from dist/md/
Accept: application/jsonReturns JSON metadata from dist/api/

This means html-star SPA navigation, markdown API requests, and JSON metadata fetches all work locally without any extra configuration.

Port configuration

The default port is 3000. Override it with the COOK_DEV_PORT environment variable:

Dev vs production builds

When running cook dev, the build executes with NODE_ENV=development. Use this to conditionally include development-only features like debug logging or analytics bypasses. The cook build command runs a standard production build without watching or serving.

Featurecook devcook build
Full buildYesYes
Live reloadYesNo
File watchingYesNo
Content negotiationYesServer-dependent
NODE_ENVdevelopment(unset)