InstantSearchOptions type defines all configuration options available when creating an InstantSearch instance.
Type Signature
Required Options
The search client to plug to InstantSearch.js. This is the only required option.Using Algolia’s default search client:Using a custom search client:
Index Configuration
The name of the main index. If no
indexName is provided, you must manually add an index widget.The objectID of the composition. If this is provided, the composition API will be used for search.
State Management
Injects an initial UI state to the InstantSearch instance. Use this option to provide an initial state to widgets.
The state is only used for the first search. To unconditionally pass additional parameters to the Algolia API, use the
configure widget.Function called when the state changes. Using this function makes the instance controlled, meaning you become responsible for updating the UI state with
setUiState.Parameters:uiState(TUiState) - The next UI statesetUiState(function) - Function to update the UI state
Routing
Router configuration used to save the UI state into the URL or any other client-side persistence. Pass Advanced routing configuration:See the routing guide for more details.
true to use default URL options.Simple routing (boolean):Insights and Analytics
Enables the Insights middleware and loads the Insights library if not already loaded.The Insights middleware automatically sends view and click events, and lets you set up custom events.Simple insights (boolean):Advanced insights configuration:
The instance of search-insights to use for sending insights events inside widgets.See the migration guide for more information.
UI Customization
The locale used to display numbers. This will be passed to Example output:
Number.prototype.toLocaleString().en-US: 1,234.56fr-FR: 1 234,56de-DE: 1.234,56
Search Behavior
Time in milliseconds before a search is considered stalled. When a search exceeds this delay, the
status property changes to "stalled".A hook that will be called each time a search needs to be done. You’re responsible for calling
helper.search().This option allows you to avoid doing searches at page load, for example.Future Flags
Options for opting into future breaking changes before the next major version.
Changes the way
dispose is used in the InstantSearch lifecycle.- If
false(default): Each widget unmounting will remove its state, even if there are multiple widgets reading that UI state. - If
true: Each widget unmounting will only remove its own state if it’s the last of its type. This allows dynamically adding and removing widgets without losing their state.
This will become the default behavior in the next major version.
Changes the way root levels of hierarchical facets have their count displayed.
- If
false(default): The count of the refined root level is updated to match the count of the actively refined parent level. - If
true: The count of the root level stays the same as the count of all children levels.
This will become the default behavior in the next major version.