{"id":18419,"library":"history-server","title":"history-server","description":"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.","status":"maintenance","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/mjackson/history-server","tags":["javascript","history","pushState","html5","express"],"install":[{"cmd":"npm install history-server","lang":"bash","label":"npm"},{"cmd":"yarn add history-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add history-server","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CJS require works as well but ESM import is preferred when using ES modules.","wrong":"const { createServer } = require('history-server')","symbol":"createServer","correct":"import { createServer } from 'history-server'"},{"note":"Package has no default export; importing default gives undefined. Use named import createServer.","wrong":"const historyServer = require('history-server').default","symbol":"default","correct":"import historyServer from 'history-server'"},{"note":"Direct require returns an object with createServer property, not the function itself.","wrong":"const createServer = require('history-server')","symbol":"createServer","correct":"const { createServer } = require('history-server')"}],"quickstart":{"code":"// CLI usage:\n// $ npx history-server app\n// Or programmatically:\nconst path = require('path');\nconst { createServer } = require('history-server');\n\nconst server = createServer([\n  {\n    path: '/',\n    root: path.join(__dirname, 'public')\n  }\n]);\n\nserver.listen(3000, () => {\n  console.log('Listening on port 3000');\n});","lang":"javascript","description":"Shows how to use history-server both via CLI and programmatically to serve a single SPA from a directory."},"warnings":[{"fix":"Wrap a single app in an array: createServer([app]).","message":"createServer no longer accepts a single app object; must pass an array since v1.0.0.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Call server.listen(port) instead of passing options.","message":"Server options (e.g., port) passed via second argument to createServer deprecated; use returned server methods.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Always use absolute paths or resolve relative to __dirname.","message":"Relative paths in proxy configuration resolve from process.cwd(), not the config file location.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use const { createServer } = require('history-server');","cause":"Importing default export instead of named export.","error":"TypeError: createServer is not a function"},{"fix":"Ensure index.html exists in the root directory of the app and the path mapping is correct.","cause":"The app's index.html not found at the root of the configured path.","error":"404 page not found for /some/path"},{"fix":"Change port via -p flag or server.listen(port) to a different port.","cause":"Another process already listening on the same port.","error":"EADDRINUSE: port already in use :::80"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}