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
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.
You can also create your own UI with
usePagination
.Examples
JavaScript
Props
The maximum number of pages to browse.
JavaScript
The number of pages to display on each side of the current page.
JavaScript
Whether to display the first page link.
JavaScript
Whether to display the previous page link.
JavaScript
Whether to display the next page link.
JavaScript
Whether to display the last page link.
JavaScript
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 disabled page element.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
Any
<div>
prop to forward to the root element of the widget.JavaScript
Hook
React InstantSearch let you create your own UI for the<Pagination>
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()
for memoization.
Arrays and objects are automatically memoized.The maximum number of pages to browse.
JavaScript
The number of pages to display on each side of the current page.
JavaScript
APIs
Hooks return APIs, such as state and functions. You can use them to build your UI and interact with React InstantSearch.The current page number.
JavaScript
The number of hits (can be approximate).
JavaScript
The number of pages for the total result set.
JavaScript
Whether the current page is the first page.
JavaScript
Whether the current page is the last page.
JavaScript
Indicates if the pagination can be refined.
JavaScript
Sets the current page and triggers a search.
JavaScript
Generates a URL of the next search state.
JavaScript