About this widget
TheuiState
object represents the state of the search UI and can be saved and returned to later.
It’s updated whenever the user interacts with the UI and can be used to:
- Store the current search query and parameters
- Pass data to widgets
- Determine which results to show when a user visits a new page (routing)
Vue InstantSearch v2
uiState
only works when the widgets responsible for each UI state attribute are mounted.
For example, asearchBox
widget is necessary to provide aquery
.
Vue InstantSearch v3 and later
TheuiState
passed to initialUiState
or through routing needs to be nested per index.
For example, if you only have a root index called INDEX_NAME
,
you should use a value like { INDEX_NAME: { query: 'query' } }
.
Example
This is an example of an InstantSearchuiState
object.
It represents what the user has searched for, how they’ve refined the results, and how the results are displayed.
JavaScript
Custom widgets
To have your custom widgets interact with theuiState
object,
you need to implement the getWidgetUiState
and getWidgetSearchParameters
methods in the connector.
For more information, see Custom widgets.