Pushstate Server is a minimalistic static file server designed to work seamlessly with HTML5 Pushstate, a browser API for manipulating browser history. It addresses the common single-page application (SPA) routing problem where direct access to a deep link (e.g., `/users/123`) would result in a 404 error because no physical file exists at that path on the server. Instead, this server is configured to return the `index.html` file for any route that does not directly map to a static asset. Conversely, requests for actual static files (e.g., `/assets/logo.png`) are served directly. The package is currently at version 3.1.0. Its release cadence appears to be very slow or effectively ceased, with the last publish on npm dating back over seven years to February 12, 2019. Key differentiators include its simple configuration for HTML5 Pushstate routing, supporting multiple directories for serving static assets, and binding to specific hosts or ports. It remains a lightweight solution for basic SPA hosting needs, though its lack of recent updates may pose compatibility or security considerations for modern development workflows.
npm install pushstate-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize and start the pushstate-server for serving static files from a single directory.
For ESM projects, use `require()` for this package or consider alternative static servers with active maintenance and ESM support. Ensure your build pipeline correctly handles CJS dependencies.
Always ensure the `directory` or `directories` option points only to trusted static asset folders. Avoid serving root directories or user-generated content directly without additional security layers. Regularly review your server's exposed paths.
Verify that your client-side routing framework (e.g., React Router, Vue Router) is configured to expect the custom entry file. Test all routes, including direct URL access and browser history navigation (back/forward buttons).
Run `npm install pushstate-server` or `npm install -g pushstate-server` if using the global CLI. Ensure the package is listed in `package.json` dependencies if it's a project-specific dependency.
Change the `port` option in your server configuration to an available port, or terminate the process currently using the desired port. You can often use `process.env.PORT` to allow dynamic port assignment.
Ensure your single-page application's client-side router is configured to read the current URL path on initial load and render the corresponding component. The `pushstate-server` provides the necessary `index.html`, but the SPA framework must take over routing from there.
No dependency data recorded yet.