Registry / web-framework / history-server

history-server

JSON →
library1.3.1jsnpmunverified

An HTTP server for single-page apps that use the HTML5 history API. Version 1.3.1 is the latest stable release, with no recent updates since 2017. It serves multiple single-page apps from various directories or different hosts on the same domain, supporting both static file serving and proxying. Unlike other SPA servers (e.g., serve, http-server), history-server is designed specifically for apps using pushState, with built-in support for multiple app configurations via config file or directory layout. It is a lightweight CLI tool but can also be used programmatically in Node.js.

npm install history-server
INSTALL
IMPORT
SIG · HISTORY-SERVER
H
history-server
web-frameworkjavascriptv1.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createServer
import { createServer } from 'history-server'
const { createServer } = require('history-server')
CJS require works as well but ESM import is preferred when using ES modules.
default
import historyServer from 'history-server'
const historyServer = require('history-server').default
Package has no default export; importing default gives undefined. Use named import createServer.
createServer
const { createServer } = require('history-server')
const createServer = require('history-server')
Direct require returns an object with createServer property, not the function itself.

Shows how to use history-server both via CLI and programmatically to serve a single SPA from a directory.

// CLI usage: // $ npx history-server app // Or programmatically: const path = require('path'); const { createServer } = require('history-server'); const server = createServer([ { path: '/', root: path.join(__dirname, 'public') } ]); server.listen(3000, () => { console.log('Listening on port 3000'); });
history-server --version
Debug
Known issues
breakingcreateServer no longer accepts a single app object; must pass an array since v1.0.0.
fix
Wrap a single app in an array: createServer([app]).
affects: >=1.0.0
deprecatedServer options (e.g., port) passed via second argument to createServer deprecated; use returned server methods.
fix
Call server.listen(port) instead of passing options.
affects: >=0.0.0
gotchaRelative paths in proxy configuration resolve from process.cwd(), not the config file location.
fix
Always use absolute paths or resolve relative to __dirname.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: createServer is not a function
Importing default export instead of named export.
fix
Use const { createServer } = require('history-server');
404 page not found for /some/path
The app's index.html not found at the root of the configured path.
fix
Ensure index.html exists in the root directory of the app and the path mapping is correct.
EADDRINUSE: port already in use :::80
Another process already listening on the same port.
fix
Change port via -p flag or server.listen(port) to a different port.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
history-server — npm install history-server · libregistry