Hash Routing

The router supports both standard HTML5 History API routing (pathnames) and Hash-based routing (#/path).

Hash routing is perfect for static file hosting environments (like GitHub Pages or Netlify static deploys) because it bypasses the need for server-side redirection fallback configurations.


setRoutingMode

Configures the router's active mode. Accepts "history" (default) or "hash".

typescript
1function setRoutingMode(mode: 'history' | 'hash'): void

Example

javascript
1import { setRoutingMode } from '@beforesemicolon/router'2 3// Enable Hash Routing4setRoutingMode('hash')5 6// URLs will now format as: domain.com/#/dashboard7// <page-link path="/todos"> renders as: <a href="#/todos">

getRoutingMode

Retrieves the currently active routing mode.

typescript
1function getRoutingMode(): 'history' | 'hash'

Example

javascript
1import { getRoutingMode } from '@beforesemicolon/router'2 3const mode = getRoutingMode() // "history" or "hash"

Benefits of Hash Routing

edit this doc