Overview
Hash routing keeps the route in the fragment (https://app.example.com/#/dashboard). Browsers never send the fragment to the server, so every route returns the same HTML document and a JavaScript router maps location.hash to a view. Choose it only when the host cannot rewrite unknown paths to the SPA shell, as on some static file hosts. For anything indexable or shareable, use History API (pushState) routing.
Rules
- Servers, server-side analytics, per-route Open Graph tags, and crawlers cannot see per-route content; crawlers treat everything after
#as one page. - Fragments are ignored when comparing canonical URLs (canonical-url).
- React Router supports both modes (
createHashRouterandcreateBrowserRouter); Next.js uses file-system routing on the History API. - A plain
<a href="#section">is in-page anchor navigation, not hash routing.
Related
- canonical-url: fragments do not create distinct URLs.
- csr: the rendering model hash routing usually pairs with.
- react: router modes.
- nextjs: History API routing.
- technical: crawl and index implications.