# rafgraph/spa-github-pages

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/rafgraph-spa-github-pages).**

4,036 stars · 566 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/rafgraph/spa-github-pages
- Homepage: https://spa-github-pages.rafgraph.dev
- awesome-repositories: https://awesome-repositories.com/repository/rafgraph-spa-github-pages.md

## Description

This project is a client-side routing solution and URL manager designed for single-page applications hosted on static platforms, specifically GitHub Pages. It enables these applications to handle deep links and maintain functional routing on hosts that do not support server-side redirects.

The system intercepts server-side 404 errors and redirects them to a main entry point, using query strings and hash fragments to preserve the application state and restore the original intended path. It also includes utilities for generating specialized, redirect-compatible links for sitemaps to ensure search engines can index pages without triggering server-side errors.

The project provides comprehensive support for route management, URL state preservation, and search engine optimization for static site environments.

## Tags

### Web Development

- [404 Page Redirections](https://awesome-repositories.com/f/web-development/url-routing/redirection-rules/404-page-redirections.md) — Intercepts static host 404 errors and redirects them to the root to enable client-side routing.
- [Client-side Routing](https://awesome-repositories.com/f/web-development/client-side-routing.md) — Provides a mechanism to intercept missing page requests and redirect them to maintain application state. ([source](https://cdn.jsdelivr.net/gh/rafgraph/spa-github-pages@gh-pages/README.md))
- [Fragment Preservation](https://awesome-repositories.com/f/web-development/fragment-navigation/fragment-preservation.md) — Maintains URL hash fragments and query parameters during redirects to ensure the correct application view loads.
- [Route Redirects](https://awesome-repositories.com/f/web-development/route-redirects.md) — Provides utilities to redirect server-side errors on static hosts back to the main entry point. ([source](https://spa-github-pages.rafgraph.dev/example))
- [Static Route Interception](https://awesome-repositories.com/f/web-development/static-route-interception.md) — Uses a custom fallback page to simulate dynamic routing on a platform that only supports static files.
- [Static Site Error Pages](https://awesome-repositories.com/f/web-development/static-site-error-pages.md) — Intercepts 404 errors on static hosts to preserve application state and redirect users to the home page.
- [Static SPA Routers](https://awesome-repositories.com/f/web-development/static-spa-routers.md) — Provides a client-side routing solution that enables single page applications to handle deep links on GitHub Pages.
- [Client-Side URL Rewriters](https://awesome-repositories.com/f/web-development/url-rewrite-rules/client-side-url-rewriters.md) — Encodes destination paths in query strings to bypass server-side routing limitations on static platforms.
- [URL State Restoration](https://awesome-repositories.com/f/web-development/url-state-restoration.md) — Reroutes missing page requests to a main entry point using query strings to recover the original application state.
- [Single Page Application Hosting](https://awesome-repositories.com/f/web-development/web-infrastructure-deployment/web-infrastructure-servers/http-servers/single-page-application-hosting.md) — Implements fallback routing to serve a single HTML file for all application paths on static hosts. ([source](https://spa-github-pages.rafgraph.dev))
- [Static Site SEO](https://awesome-repositories.com/f/web-development/static-site-seo.md) — Creates search engine friendly links for single page apps hosted on platforms without server-side redirects.
- [Sitemap Generators](https://awesome-repositories.com/f/web-development/web-standards/search-engine-optimization/sitemap-generators.md) — Generates search engine friendly links that function correctly on static hosting services.
- [Redirect-Compatible Sitemaps](https://awesome-repositories.com/f/web-development/web-standards/search-engine-optimization/sitemap-generators/redirect-compatible-sitemaps.md) — Generates specialized sitemap URLs that bypass server-side errors by encoding the intended destination path. ([source](https://spa-github-pages.rafgraph.dev/sitemap-link-generator))
- [SEO Link Encoding](https://awesome-repositories.com/f/web-development/web-standards/search-engine-optimization/sitemap-generators/seo-link-encoding.md) — Transforms standard paths into specialized links that bypass server-side errors for search engine indexing.

### User Interface & Experience

- [URL Parameter Persistence](https://awesome-repositories.com/f/user-interface-experience/event-driven-state-managers/event-driven-state-synchronizers/ui-state-recomposition/state-to-ui-mapping/state-to-url-mappings/url-parameter-persistence.md) — Ensures the browser maintains the correct path and query parameters when redirecting back to the main entry point.

### DevOps & Infrastructure

- [SPA Routing Configurations](https://awesome-repositories.com/f/devops-infrastructure/deployment-management-strategies/static-site-deployments/portfolio-hosting/github-pages-deployments/spa-routing-configurations.md) — Enables hosting of single page applications on GitHub Pages while maintaining functional client-side routing.

### Security & Cryptography

- [Sitemap Redirects](https://awesome-repositories.com/f/security-cryptography/user-authentication-flows/deep-link-redirects/sitemap-redirects.md) — Transforms standard URLs into redirect-compatible links for sitemaps to enable indexing despite server-side errors. ([source](https://cdn.jsdelivr.net/gh/rafgraph/spa-github-pages@gh-pages/README.md))
