lws-spa is a middleware plugin for lws (local-web-server) that adds Single Page Application support. As of version 4.1.1 (stable, active maintenance), it allows you to serve a SPA by providing a fallback file (e.g., app.html) that is returned for non-asset requests, with configurable asset detection using regular expressions or filesystem checks. It integrates seamlessly into lws's plugin architecture and is updated occasionally; the package is part of the lws ecosystem and targets Node.js >=12.17. Compared to generic static file servers, lws-spa provides SPA-specific options like asset testing via regex or filesystem, making it a focused solution for SPA development.
npm install lws-spaVerified import paths — ran on the pinned version, not inferred.
Creates an lws server with SPA support using lws-spa middleware and serves app.html as fallback for all non-asset requests.
Update to Node.js >=12.17 and lws >=4.
Use --spa.asset-test-fs (with dots) or the equivalent object config.
Use --spa.asset-test (with dot).
Always provide the `spa` file path, e.g., --spa app.html.
Set a more specific regex or use asset-test-fs if needed.
Use import() dynamic import or switch to ESM in your project.
import lwsSpa from 'lws-spa' instead of import { lwsSpa } from 'lws-spa'.Add `--spa app.html` to your lws command line or set `spa: 'app.html'` in the config.