Skip to main content
You are viewing the documentation for InstantSearch.js v4. To upgrade from v3, see the migration guide. Looking for the v3 version of this page? View the v3 docs.
Signature

Import

About this widget

The instantsearch object is the root wrapper component for all widgets. Two parameters are required: See also: Get started with InstantSearch.js

Middleware

InstantSearch.js provides middleware to help you connect to other systems:

Examples

JavaScript

Options

string
required
The main index to search into.
JavaScript
object
required
Provides a search client to instantsearch. Read the custom backend guidance on implementing a custom search client.
JavaScript
string
The locale used to display numbers. This is passed to Number.prototype.toLocaleString().
JavaScript
function
deprecated
Use onStateChange instead.This option lets you take control of search behavior. For example, to avoid doing searches at page load.When this option is set, search.helper won’t emit events. Instead, use onStateChange or widgets to handle search behavior.A hook is called for every (with Algolia’s search helper as a parameter). Begin searching by calling helper.search().When modifying the state of the helper within search-function, the helper resets the page to 0. To keep the current page, store the page information, modify the state, and reapply pagination.
JavaScript
object
Adds a uiState to your instantsearch instance, which provides an initial state to your widgets.Since this sets the initial state for your UI, you need to include the corresponding widgets in your app. For example, page: 5 as initial state only has an effect if you include the pagination widget as well.Replace YourIndexName with the name of your Algolia index.
JavaScript
function
Triggered when the state changes. This can be helpful for performing custom logic on a state change.When using onStateChange, the instance is under your control. You’re responsible for updating the UI state (with setUiState).
JavaScript
number
default:200
A time period (in ms) after which the search is considered to have stalled. Read the slow network guide for more information.
JavaScript
boolean | object
default:false
The router configuration used to save the UI state into the URL or any client-side persistence.For more information, see Sync your URLs.You can’t use initialUiState with routing as the two options override each other.
  • Use initialUiState for simple and static use cases.
  • Use routing for anything complex or dynamic.
boolean | object
default:false
since: v4.55.0
Enables the Insights middleware and loads the search-insights library (if not already loaded). The Insights middleware sends view and click events automatically, and lets you set up your own click and conversion events.To use this option with an object, refer to the Insights middleware options.
function
deprecated
Use insights instead.This function is exposed by the search-insights library (usually window.aa) and is required for sending click and conversion events with the insights middleware.
JavaScript
object
Test new InstantSearch features without affecting others.

Methods

function
Adds widgets to the instantsearch instance.You can add widgets to instantsearch before and after you start it.
JavaScript
deprecated
Use addWidgets([widget]) instead.Adds a widget to the instantsearch instance.You can add widgets to instantsearch before and after you start it.
JavaScript
function
Finalizes the setup of instantsearch and triggers the first search.Call this method after you have added all your required widgets to instantsearch. You can also add widgets after instantsearch has started, but these widgets aren’t considered during searches made before you add them.
JavaScript
Removes widgets from the instantsearch instance. You can only do this after you start instantsearch.The widgets you remove from instantsearch must implement a dispose() method to reset the search parameters they manage.
JavaScript
deprecated
Use removeWidgets([widget]) instead.Removes a widget from the instantsearch instance. You can only do this after you start instantsearch.The widget you remove from instantsearch must implement a dispose() method to reset the search parameters they manage.
JavaScript
Removes all widgets from the instance. This method doesn’t trigger a search.
JavaScript
Injects a uiState into the instance without relying on internal events (such as connectors’ refine or widget interactions).For this option to work, the widgets responsible for each UI state attribute must be mounted. For example, a searchBox is necessary to provide a query.
Clears the Algolia responses cache and triggers a new search. For more information, read the InstantSearch caching guide.
JavaScript

Properties

string
The status of the in-progress search.Possible values are:
  • idle. No search is in progress.
  • loading. The search is loading. Use loading for immediate feedback on an action. For loading indicators, use 'stalled' instead.
  • stalled. The search is stalled. This is triggered after stalledSearchDelay expires.
  • error. The search failed. The error is available in the error property.
JavaScript
Error | undefined
The error that occurred during the search. This is only defined when status is 'error'.
JavaScript
RenderState | undefined
The renderState provides access to all the data to render the widgets, including the methods to refine the search. More information can be found in the renderState page.
JavaScript

Events

Triggered when all widgets are rendered. This happens after every search request.
JavaScript
Triggered when calling the API reports an error.
JavaScript
Last modified on July 22, 2026