UI libraries
/
InstantSearch.js
/
Widgets
Dec. 04, 2023
singleIndex
Signature
singleIndex( indexName: string, );
Import
Copy
1
import { singleIndex } from 'instantsearch.js/es/lib/stateMappings';
About this widget
The singleIndex
state mapping can be applied to the instantsearch
object’s routing option.
It enables backward compatibility with version 3.x.x.
The mapping applies the following transformations:
- Omits the
configure
widget - Uses the given index for the top level
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
singleIndex('instant_search').stateToRoute({
instant_search: {
query: 'Apple',
page: 5,
configure: {
hitsPerPage: 4,
},
},
});
// {
// query: 'Apple',
// page: 5,
// }
Examples
Copy
1
2
3
4
5
6
instantsearch({
// ...
routing: {
stateMapping: singleIndex('instant_search'),
},
});
Options
Parameter | Description | ||
---|---|---|---|
indexName
|
type: string
Required
The name of the index to get the state from, usually the same value provided to |
||
Copy
|
Did you find this page helpful?