Dev

Options that only affect the development server (nitro dev).

Note

All examples on this page assume the following import in nitro.config.ts:

import { defineConfig } from "nitro";

#devServer

  • Default: { watch: [] }

Dev server options. You can use watch to make the dev server reload if any file changes in specified paths.

Supports port, hostname, watch, runner, drain, and devtoolsJson options.

export default defineConfig({
  devServer: {
    port: 3001,
    watch: ["./server/plugins"],
  },
});

By default, the dev server serves /.well-known/appspecific/com.chrome.devtools.json so Chrome DevTools can connect your project folder as an automatic workspace and save edits back to source files. The workspace UUID is persisted in buildDir. Set devServer.devtoolsJson: false to disable it.

By default, a reload shuts the previous dev worker down first: new requests wait for it, and requests, streamed responses and WebSockets still open after 5 seconds are cut. Set devServer.drain: true to let it finish them while new requests go to the new worker. It is shut down once they settle, or after 60 seconds (drain: { timeout: 600_000 } for a custom limit, Infinity for none).

#watchOptions

Watch options for development mode. See chokidar for more information.

export default defineConfig({
  watchOptions: {
    ignored: ["**/node_modules/**", "**/dist/**"],
  },
});

#devProxy

Proxy configuration for development server.

You can use this option to override development server routes and proxy-pass requests.

export default defineConfig({
  devProxy: {
    "/proxy/test": "http://localhost:3001",
    "/proxy/example": { target: "https://example.com", changeOrigin: true },
    "/proxy/socket/**": { target: "http://localhost:3002", ws: true },
  },
});

Routes match like other Nitro routes: /proxy/test only matches that exact path, use /proxy/test/** to also proxy sub-paths. Set ws: true to also proxy WebSocket upgrade requests.

See httpxy for all available target options.

Note

When the dev server runs on Bun or Deno (e.g. bun --bun nitro dev), it listens with the runtime's native server. HTTP requests are then proxied with proxyFetch from httpxy, supporting target, headers, auth, xfwd, changeOrigin, secure, ssl, agent, prependPath, ignorePath, proxyTimeout and followRedirects. WebSockets are proxied with the crossws proxy, supporting target, headers, auth, xfwd, prependPath and ignorePath (the upstream Host header always matches the target). WebSocket upgrades to the dev worker of the miniflare runner (Cloudflare presets) are only supported on Node.js.

Nitro  builds full-stack servers that deploy anywhere.