history
history({ // Optional parameters windowTitle: function, createURL: function, parseURL: function, writeDelay: number, getLocation: function, });
1
import { history } from 'instantsearch.js/es/lib/routers';
About this widget
You are currently reading the documentation for InstantSearch.js V4. Read our migration guide to learn how to upgrade from V3 to V4. You can still access the V3 documentation for this page.
The history
router is the one used by default within instantsearch
.
The router provides an API that lets you customize some of its behaviors. To get a sense of what you can do with the API, see the dedicated guide on Routing URLs.
Examples
1
2
3
4
5
6
instantsearch({
// ...
routing: {
router: history(),
},
});
Options
windowTitle
|
type: function
Optional
This function lets you dynamically customize the window title based on the provided |
||
Copy
|
|||
createURL
|
type: function
Optional
This function lets you directly change the format of URLs that are created and rendered for the browser URL bar or widgets. It’s called every time InstantSearch needs to create a URL. The provided options are:
|
||
Copy
|
|||
parseURL
|
type: function
Optional
This function is responsible for parsing the URL string back into a
|
||
Copy
|
|||
writeDelay
|
type: number
default: 400
Optional
This option controls the number of milliseconds the router waits before writing the new URL to the browser. You can think about it this way: “400 ms after the last user action, the URL is pushed to the browser”. This helps reduce:
400 ms is a typically a pretty good |
||
Copy
|
|||
getLocation
|
type: function
default: () => window.location
Optional
This function lets you return a custom implementation of By default, it generates an error if there isn’t a custom implementation outside a browser environment. |
||
Copy
|