Skip to main content
This is the React InstantSearch v7 documentation. If you’re upgrading from v6, see the upgrade guide. If you were using React InstantSearch Hooks, this v7 documentation applies—just check for necessary changes. To continue using v6, you can find the archived documentation.
Signature

About this widget

The middleware function returns an object with onStateChange, subscribe, and unsubscribe functions. The middleware function doesn’t perform any actions itself but lets you inject logic into InstantSearch.js, for example, sending events to Google Analytics. To send Algolia click and conversion events, use the insights middleware.

Requirements

Examples

JavaScript

Options

object
required
You have access to the instance of instantsearch which lets you read values from the instance or call instance methods like addWidgets, setUiState, and refresh.
JavaScript

Hooks

({ uiState }) => void
required
The function is called with uiState whenever the state changes.
JavaScript
() => void
required
This function is called when the InstantSearch instance starts (when search.start is called). This is where you can add event listeners, subscribe to an API, and run any side effects.
JavaScript
() => void
required
The function is called when the InstantSearch instance is disposed of. You can clean up anything you initiated in the subscribe function.
JavaScript
Last modified on July 22, 2026