Serve static, SPA, proxy and WebSocket — from a single binary.
servd is a self-contained development, testing and lightweight hosting server — a drop-in alternative to http-server with first-class proxies, TLS and a self-supervising daemon.
Install
npm install --global @qingyu31/servd $ servd --spa=./frontend --proxy=/api/=http://localhost:9000/api/ --ws=/ws=ws://localhost:9000/ws --port=8080servd 0.1.0 listening on 0.0.0.0:8080 (all IPv4 interfaces)Hosts: unrestricted spa / -> /app/frontend proxy /api -> http://localhost:9000/api/ proxy /ws -> ws://localhost:9000/ws▋Why servd
Zero configuration
No config file and no required flags: run servd and it serves the current directory. Everything else is opt-in per-mount flags.
Static & SPA
Serve one or more directories at mount prefixes, with content-negotiated SPA fallback to index.html.
HTTP proxy
Forward a mount prefix to an upstream URL with path rewriting. Longest mount wins; proxies beat files.
WebSocket proxy
Tunnel ws:// and wss:// upstreams through the same port as your static site and API.
HTTPS & WSS
Terminate TLS 1.2+ from a PEM cert and key. The port serves both HTTPS and WSS over HTTP/1.1.
CORS & host filters
Allow a wildcard or explicit origins (no credentials), and restrict which Host headers are accepted.
Daemon mode
Run detached with a supervisor that restarts a crashed worker using exponential backoff.
Zero dependencies
A single static binary distributed via npm as per-platform packages. No Node runtime needed to serve.
How it compares to http-server and nginx
| Capability | http-server | nginx | servd |
|---|---|---|---|
| Zero-config start | Yes (single root) | No (needs a config file) | Yes (serves the current directory) |
| Config file & reload | Flags only | nginx.conf + reload | None; flags only |
| Multiple HTTP proxy mounts | No (single --proxy fallback) | Yes (location blocks) | Yes (--proxy, repeatable) |
| Proxy path rewriting | No | Yes (rewrite) | Yes (mount=target) |
| WebSocket proxy | No | Yes (Upgrade headers) | Yes (--ws) |
| SPA fallback | Basic | Yes (try_files) | Yes (content-negotiated) |
| CORS | Yes | Manual headers | Yes (--cors) |
| TLS / HTTPS | Yes | Yes | Yes (TLS 1.2+, HTTP/1.1) |
| Background daemon with restart | No | Yes (master/worker) | Yes (--daemon) |
| Runtime & learning curve | Node.js; low | Separate server; steep | None (single static binary); low |
Use cases
View allPreview a local build
Point servd at dist/, build/ or _site/ to preview a production build in one command — no Node runtime, correct caching and gzip/brotli out of the box.
Local debug proxy (SPA + API + WebSocket)
Put your front-end build and back-end behind one port while debugging locally. servd serves the SPA, rewrites /api to your server, and tunnels /ws — the browser sees a single origin and no CORS setup is needed.
Lightweight hosting
Point one static binary at a folder and keep it served — internal tools, demos, coverage reports or small sites — with optional TLS, host filtering and a self-restarting daemon.
From the blog
View allReplacing http-server with servd
A practical migration from npm's http-server to servd — equivalent commands, what changes, and what you gain.
Introducing servd
A single-binary static, SPA, HTTP and WebSocket server for development, testing and light hosting — distributed over npm.
One port, one origin: proxying WebSockets with servd
How servd tunnels WebSocket upgrades alongside HTTP on a single port, and why that removes CORS from your dev loop.