Overview
This page is the atomic definition. Routing patterns live at react and nextjs.
Definition
Hash routing encodes navigation state in the URL fragment, the string after # (e.g., https://app.example.com/#/dashboard). Browsers never send the fragment to the server, so all hash-route requests return the same root HTML document. A JavaScript router reads window.location.hash, maps it to a component, and renders it client-side. Advantages: works on static hosts with no server-side routing configuration and does not require a catch-all 404 handler. Disadvantages: the fragment is excluded from HTTP requests, so server-side analytics, Open Graph tags, and search-engine indexers cannot see per-route content reliably. Prefer History API routing (pushState) for any publicly indexable application. Hash routing remains useful for documentation anchors, in-page navigation, and apps deployed to CDNs that cannot configure fallback routes.
When it applies
Use hash routing for single-page apps deployed to static hosts where configuring a catch-all route is not possible, or for in-page anchor navigation. Use History API routing for any app where SEO, social sharing, or server-side rendering matters.
Example
https://docs.example.com/page.html#getting-started
Clicking a <a href="#getting-started"> scrolls to the anchor and updates location.hash without a server request.
Related concepts
- react - React Router supports both hash and history modes.
- nextjs - Next.js uses History API routing with file-system-based routes.
- technical - hash URLs limit crawler access to per-route content.
- canonical-url - hash segments are excluded from canonical URL comparison.
Citing this term
See Hash routing (llmbestpractices.com/glossary/hash-routing).