
Native HTTP + HTTPS · Node.js 22.12+ · CommonJS + Node.js ESM
Start an HTTP or HTTPS static server.
Serve the same static-file contract over HTTP, HTTPS-only, or paired listeners with ranges, cache validation, optional compression, clean shutdown, and zero runtime dependencies.
file:// are not supported runtime paths.CLI quick start
Serve a folder locally.
Install the command globally, or use npx. The default listener is reachable only from this machine.
npm install --global node-http-server
node-http-server --root ./publicnode-http-server listening at http://127.0.0.1:8080
npx node-http-server --root ./public. See the CLI task guide for flags, failures, exit behavior, and deployment examples.Library quick start
Create an isolated server.
const {Server}=require('node-http-server');
new Server({root:'./public'}).deploy();import {Server} from 'node-http-server';
new Server({root:'./public'}).deploy();The original default singleton remains available in both module systems. New applications should normally create a named Server instance so listener and configuration state stay isolated.
Starting behavior
Know the defaults before changing them.
| Behavior | Default | Change it |
|---|---|---|
| Request-body limit | Unlimited | server.maxRequestBodyBytes |
| Compression | Off | server.compression |
| SPA fallback | Off | server.spaFallback |
| Dotfiles | Blocked with 403 | server.allowDotfiles |
| Automatic MIME types | Built-in map | contentType |
| Request logging | Off | log |
| HTTPS | Off | https |
host:'0.0.0.0' or --host 0.0.0.0 only when other machines should connect. Read Operations and security first.Documentation by task
Go directly to the job.
Decision signals, project fit, interfaces, boundaries, and engineering evidence.
Why node-http-server → Run the commandInstall, flags, common tasks, expected output, and failure behavior.
CLI → Embed the serverImports, lifecycle, public methods, request data, and hooks.
Library API → Set exact behaviorEvery Config key, default, opt-out value, and validation rule.
Configuration → Serve with HTTPSHTTPS-only and paired listeners, key/certificate settings, lifecycle, and deployment patterns.
HTTPS guide → Copy a working patternSPA, HTTPS, domains, logging, hooks, limits, and shutdown.
Examples → Generate a configBuild CommonJS, Node.js ESM, CLI, or JSON without running a server.
Playground → Test and measureTest commands, coverage gates, reports, badges, and CI artifacts.
Testing → Inspect performance9.0.2 comparison results, workload contracts, raw samples, and reproduction.
Performance → Operate or upgradeExposure, status failures, logging, certificates, and migration to v10 HTTP/2.
Operations → Browse the docs hubA compact map of every page and the source documents.
Docs hub →Project status