documentation menu

SPA mode & error pages

Serve /index.html for unmatched routes so client-side routers work, and map status codes to your own pages.

read as markdown

Two options cover the common routing cases for static sites.

Single-page apps

Add --spa and any path that doesn’t match a file is served /index.html with a 200 — so client-side routers (React Router, Vue Router, TanStack Router) handle deep links instead of returning a 404.

spa
$ one9x pages release ./dist --site myapp --spa --deploy✓ Live · unknown routes → /index.html

This is the flag that decides whether an app works. Without it, the first visitor who hard-refreshes on /settings or follows a shared deep link gets a 404 — the app is fine, the routing never got a chance to run.

You need it for a client-rendered app (Vite + React Router, Vue Router, Create React App). You don’t need it for a static site generator that writes a real HTML file per route — Astro, Hugo, Eleventy, Next.js output: 'export' — where an unmatched path genuinely is a 404 and should say so. Frameworks has the per-framework answer.

SPA mode only rewrites paths that look like routes. A path whose last segment has a file extension other than .html — /assets/app.js, /logo.png — is treated as a file, so if it is missing it still gets a 404 rather than your app shell. A route with a dot in its last segment, like /users/jane.doe, counts as a file too, so it 404s on a hard refresh.

--spa and --index are the same slot and conflict. --index names the file to serve for / instead of /index.html, for a build that has none — and, being the same slot, for unmatched routes too; --spa is the shorthand for --index /index.html. Pass one or the other.

Custom error pages

Map a status code to a page in your build with --error code:path.

error pages
$ one9x pages release ./dist --site mysite --deploy \  --error 404:/404.html✓ Live · custom 404

Only 404 is served today. The flag repeats and accepts any code from 200 to 599, but a mapping for any other code is stored with the release and not used.

The path is a path within the release — it has to be a file the build actually produced, at the exact path it lives at. --error 404:/404.html with the file at /404/index.html maps to nothing.

--spa and --error 404: fill the same slot: an explicit --error 404: entry replaces the SPA fallback, so unmatched routes get your 404 page, with a 404 status, instead of /index.html. The dashboard says the same when you upload there: “An entry for 404 overrides the choice above”. For a single-page app, pass --spa alone; a missing file then gets a plain 404.