Night Owl logoNight Owl

Serve

Use the serve command to run a local server while you work.

In your package.json, add the Night Owl serve command to scripts.

{
  "scripts": {
    "serve": "night-owl --serve"
  }
}

You can now run the serve script from the command line.

npm run serve

When the local server is running, Night Owl will log the address on the command line.

Combining watch and serve

Usually, you will call serve and watch together.

{
  "scripts": {
    "start": "night-owl --watch --serve"
  }
}

Live reloading

When Night Owl detects a change to a template, it will reload the page in the browser.

However, some assets don’t require a full page reload. When images or CSS files change, Night Owl intelligently iterates through the DOM and only reloads the asset that has changed.

Setting the host and port

You can configure which host and port to use in your Night Owl configuration.

The default host is set to "0.0.0.0", which allows access to all devices on the local network. The default port is 8080.

export default {
  // Use a different port
  port: 3000,

  // Disallow access over the local network
  host: "127.0.0.1",
}

If the port is unavailable, Night Owl will increment the port number a handful of times to find one that is free to use.

Page data

This page was rendered with the following data.

{
  "layout": "_/layouts/docs",
  "menu": {...},
  "filters": {...},
  "helpers": {...},
  "version": "0.5.4",
  "github": "https://github.com/stephenhutchings/night-owl/",
  "npm": "https://www.npmjs.com/package/night-owl",
  "hash": "lmu1z5z4",
  "thumbnail": "https://night-owl.s-ings.com/assets/thumb.png",
  "isDev": false,
  "tags": [ "commands" ],
  "title": "Serve",
  "description": "Run a local server while you develop your site",
  "url": "/docs/commands/serve/",
  "meta": {
    "url": "/docs/commands/serve/",
    "src": "src/docs/02-commands/03-serve.md",
    "dist": "dist/docs/commands/serve/index.html",
    "collections": {
      "all": [...],
      "intro": [...],
      "commands": [...],
      "configuration": [...],
      "advanced": [...],
      "templates": [...]
    }
  },
  "content": "<p>Use the serve command to run a local server while you&nbsp;work.</p>\n<p>In yo..."
}