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

Import

JavaScript

See this widget in action

Preview this widget and its behavior.

About this widget

<Stats> is a widget that displays the total number of matching hits and the time it took to get them (time spent in the Algolia server).
You can also create your own UI with useStats.

Examples

JavaScript

Props

Partial<StatsClassNames>
The CSS classes you can override and pass to the widget’s elements. It’s useful to style widgets with class-based CSS frameworks like Bootstrap or Tailwind CSS.
  • root. The root element of the widget.
JavaScript
Partial<StatsTranslations>
A dictionary of translations to customize the UI text and support internationalization.
  • rootElementText. The text for the statistics.
JavaScript
React.ComponentProps<'div'>
Any <div> prop to forward to the root element of the widget.
JavaScript

Hook

React InstantSearch let you create your own UI for the <Stats> widget with useStats. Hooks provide APIs to access the widget state and interact with InstantSearch. The useStats Hook returns APIs.

Usage

First, create your React component:
JavaScript
Then, render the widget:
JavaScript

APIs

Hooks return APIs, such as state and functions. You can use them to build your UI and interact with React InstantSearch.
number
The maximum number of hits returned per page.
number
The number of hits matched by the query.
boolean
Indicated whether relevant sort is applied to the result.
number
The number of sorted hits from relevant sort.
number
The number of returned pages. The calculation is based on the total number of hits (nbHits) divided by the number of hits per page (hitsPerPage), rounded up to the nearest integer.
number
The position of the current page (zero-based).
number
The time the server took to process the request, in milliseconds. This doesn’t include network time.
string
The query send to the server.

Example

Last modified on July 22, 2026