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
Pagination is a widget that displays a pagination to browse pages.
Pagination is limited to 1,000 hits per page.
For more information, see Pagination limitations.
Examples
JavaScript
Props
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.noRefinementRoot. The root element when there are no refinements.list. The list element.item. Each item element.firstPageItem. The first page element.previousPageItem. The previous page element.pageItem. Each page element.selectedItem. The selected page element.disabledItem. Each page element when it’s unavailable.nextPageItem. The next page element.lastPageItem. The last page element.link. The link of each item.
JavaScript
A mapping of keys to translation values.
firstPageItemText. The text for the first page item.previousPageItemText. The text for the previous page item.nextPageItemText. The text for the next page item.lastPageItemText. The text for the last page item.pageItemText. The text for the current page item.firstPageItemAriaLabel. The label for the first page item (for screen readers).previousPageItemAriaLabel. The label for the previous page item (for screen readers).nextPageItemAriaLabel. The label for the next page item (for screen readers).lastPageItemAriaLabel. The label for the last page item (for screen readers).pageItemAriaLabel. The label for the current page item (for screen readers).
JavaScript
Hook
React InstantSearch let you create your own UI for thePagination widget with usePagination.
Hooks provide APIs to access the widget state and interact with InstantSearch.
The usePagination Hook accepts parameters and returns APIs.
It must be used inside the InstantSearch component.
Usage
First, create your React component:JavaScript
JavaScript
Parameters
Hooks accept parameters. You can either pass them manually or forward props from a custom component.When passing functions to Hooks, ensure stable references to prevent unnecessary re-renders.
Use
useCallback() to keep function references stable.
You don’t need to do this for arrays and objects.APIs
Hooks return APIs, such as state and functions. You can use them to build your UI and interact with React InstantSearch.The list of pages based on the current page and
padding.JavaScript