Available Routers
history
The history router uses the browser’s History API (pushState and popstate) to manage URL synchronization.
history() Options
Function that returns the page title based on the route state.
Time in milliseconds to wait before writing to the URL. This prevents adding too many entries to the browser history.
Function to create a URL from the route state.
Function to parse the URL into route state.
Function that returns the current location object. Useful for server-side rendering or testing.
Custom function to start listening for URL changes. Advanced use only.
Custom function to clean up when routing is disposed. Advanced use only.
Custom function to push URL changes. Advanced use only.
Whether to clean up the URL when InstantSearch is disposed. Setting this to
false preserves active refinements in the URL when closing modals or unmounting the component.Router Methods
Router instances provide these methods:read()
Reads the current URL and returns the route state.write(routeState)
Writes the route state to the URL.createURL(routeState)
Creates a URL string from the route state.onUpdate(callback)
Registers a callback for URL changes.dispose()
Cleans up event listeners and optionally cleans the URL.Examples
Basic History Router
Custom Window Title
Custom URL Structure
Faster URL Updates
Preserve URL on Unmount
Server-Side Rendering
Router Type
The router must implement this interface:Custom Router Implementation
You can create a custom router by implementing the Router interface:Related
- State Mappings - Transform state to/from URL
- Routing Guide - Complete routing documentation