concept

Hash-Based Routing

Hash-based routing is a client-side routing technique used in single-page applications (SPAs) where the URL fragment identifier (the part after the # symbol) is used to manage application state and navigation without triggering full page reloads. It works by listening for changes to the hash portion of the URL and updating the UI accordingly, allowing for bookmarkable and shareable URLs within the app. This approach is particularly useful for SPAs that need to maintain state across navigation events while avoiding server-side requests for each route change.

Also known as: Hash Routing, Fragment Routing, Hashbang Routing, Client-Side Hash Routing, SPA Hash Routing
🧊Why learn Hash-Based Routing?

Developers should use hash-based routing when building SPAs that need to support deep linking and browser history without server-side configuration, as it relies solely on client-side JavaScript and doesn't require server support for routing. It's ideal for applications hosted on static file servers or CDNs where server-side routing isn't feasible, such as in GitHub Pages or simple web apps. However, it's less common in modern frameworks due to the rise of HTML5 History API-based routing, which offers cleaner URLs without the hash symbol.

Compare Hash-Based Routing

Learning Resources

Related Tools

Alternatives to Hash-Based Routing