home / dev-tools / serve

serve

Official · Vercel
9.8k

Static file server CLI for previewing local sites, SPAs, and directories over HTTP or HTTPS.

$npx serve
Language
TypeScript
Stars
9,831
Category
Dev Tools
Agent
AI Analysis

serve is Vercel's CLI for quickly exposing a local directory, static site build, or single-page app over HTTP or HTTPS. It is mainly a lightweight local hosting primitive for previews, demos, browser tests, and LAN sharing rather than a broader deployment surface.

What It Enables
  • Serve a folder, static site build, or single-page app from the terminal for local preview and browser-based testing.
  • Bind the server to custom TCP ports, Unix sockets, Windows named pipes, or HTTPS endpoints, with optional CORS, compression, and SPA rewrites.
  • Share a directory with a built-in listing UI and serve.json configuration when you need a quick disposable web endpoint without setting up a full web server.
Agent Fit
  • Useful in automation when a workflow needs a deterministic local web server process before running HTTP checks or browser tests.
  • Flags are straightforward and non-interactive, but startup and request logs are plain text only, so verification usually happens over the served HTTP endpoint rather than by parsing CLI output.
  • Best as a supporting primitive inside local web-app loops, not as a rich inspect or mutate surface on its own.
Caveats
  • It is a long-running process, so unattended use needs process supervision and explicit port cleanup.
  • serve.json is configuration input, not a machine-readable output mode.