Function: createBrowserHistory()
Documentation / @xmachines/play-router / createBrowserHistory
function createBrowserHistory(options): BrowserHistory;Defined in: create-browser-history.ts:99
Create browser history that wraps window.history
Aligned with TanStack Router’s history interface for API parallelism.
Architecture:
- Patches window.history.pushState/replaceState to detect changes
- Listens to popstate for browser back/forward
- Provides subscribe() for listeners (like PlayRouterProvider)
- Testable (accepts window object)
Usage:
const history = createBrowserHistory({ window });
const unsubscribe = history.subscribe((location) => { console.log("URL changed:", location.pathname);});
history.push("/new-path");
// Later:unsubscribe();history.destroy();Parameters
| Parameter | Type |
|---|---|
options | { window: BrowserWindow; } |
options.window | BrowserWindow |