# serve

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

Stars: 9.9k · Language: TypeScript · License: MIT · Categories: Dev Tools

- Repository: https://github.com/vercel/serve
- Website: https://npmjs.com/package/serve
- Page: https://www.trmn.sh/tools/serve

## Install

- npm: `npm install --global serve`
- npx: `npx serve`

## Overview

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

```bash
# via npm
npm install --global serve
```

```bash
# via npx
npx serve
```

![serve directory listing UI](https://media.trmn.sh/cached/56844323b688767d3aa00c90a26f473bf9e1f35b4145011753efc7e6934c96de.png)

## Alternatives

- [npm-check-updates](https://www.trmn.sh/tools/npm-check-updates.md): CLI that upgrades package.json dependencies to their latest versions, preserving semver range operators. Works with npm, yarn, pnpm, deno, and bun. (TypeScript, 10.3k stars)
- [ni](https://www.trmn.sh/tools/ni.md): Detects a project's package manager from its lockfile and translates ni, nr, nlx, nup, nun, nci commands for npm, yarn, pnpm, bun, deno, nub and aube. (TypeScript, 8.3k stars)
- [concurrently](https://www.trmn.sh/tools/concurrently.md): Node.js CLI that runs multiple shell commands in parallel with prefixed, colored output and options to kill or restart processes. Works on Windows. (TypeScript, 7.9k stars)
- [tsx](https://www.trmn.sh/tools/tsx.md): TypeScript Execute (tsx): a CLI for running TypeScript files directly in Node.js. (TypeScript, 12.2k stars)
- [clasp](https://www.trmn.sh/tools/clasp.md): Command-line tool for developing Google Apps Script projects locally: push/pull code, manage versions and deployments, tail logs, and run functions. (TypeScript, 5.9k stars)

---

Canonical: https://www.trmn.sh/tools/serve
