What is GitHub Pages SPA 404 Helper?
GitHub Pages serves static files and does not know client-side routes unless a matching file exists. A single-page app can show 404 when a visitor opens a deep route directly. A 404 fallback can redirect the browser back to the app entry point while preserving the requested path for the router.
quickAnswer
Generate a 404.html fallback for single-page apps deployed on GitHub Pages. The fallback redirects deep client-side routes to the app entry point while preserving the original path for the router to handle.
Last updated: 2026-06-11
limitations
- This is a generic client-side fallback, not a server-side redirect configuration. It relies on JavaScript in the browser to extract the original path and pass it to the router.
- The client-side router must be configured to read the preserved path from the query string or hash and render the matching route. Not all routers handle this redirect pattern automatically.
- This approach does not fix navigation or refresh behavior within the SPA after the initial redirect. Router-level configuration is still needed for full client-side routing support.
Sources:MDN Web Docs · W3C Specifications · jquery.app on GitHub
How to use this tool
- Enter the app base path. Use / for a user or custom domain site, or /repo-name/ for a project page.
- Choose whether the fallback should store the original path in the query string or hash.
- Copy the generated 404.html file into the published site root.
- Test a deep route directly after deployment.
What you can use it for
- Fix direct visits to client-side routes on GitHub Pages.
- Prepare a 404 fallback for React, Vue, Svelte, or vanilla routers.
- Document the base path needed for project pages.