serve

Node.js CLI that serves a static site, single page application, or single file over HTTP, with a browsable directory listing UI.

install

serve is a Node.js command-line static file server. Run in a project directory, it serves a static site, a single page application, or an individual static file, reachable on the local machine or over the local network. When a directory is served without an index page, it renders a directory listing interface for browsing its contents.

Usage is minimal: npx serve runs it without installing, or it can be installed globally with npm and run as serve in the current directory or as serve folder-name/ to serve a specific folder. serve --help lists all available options. Use a supported Node.js version matching the installed serve release.

Behavior is customized by placing a serve.json file in the public folder, which accepts the options documented for serve-handler. serve-handler is the core of the tool and can also be used as middleware in an existing Node HTTP server (for example http.createServer or micro). The tool suits web developers who need to preview built output or test a static site or SPA locally.

Installation

# via npm
npm install --global serve
# via npx
npx serve

serve directory listing UI

Alternatives & related tools

add a badge to your README

Maintain serve? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/serve.svg)](https://www.trmn.sh/tools/serve?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/serve?utm_source=badge"><img src="https://www.trmn.sh/badge/serve.svg" alt="Featured on trmn" height="20"></a>