Signature
See this widget in action
Preview this widget and its behavior.
About this widget
Thepagination widget displays a pagination system which lets users change the current page of search results.
Pagination is limited to 1,000 hits per page.
For more information, see Pagination limitations.
Examples
JavaScript
Options
Where to scroll after a click.
Set to
false to turn it off.The templates to use for the widget.
JavaScript
The CSS classes you can override:
root. The root element of the widget.noRefinementRoot. The root container without results.list. The list of results.item. The item in the list of results.firstPageItem. The first item.lastPageItem. The last item.previousPageItem. The previous item.nextPageItem. The next item.pageItem. The page items.selectedItem. The selected item.disabledItem. The item when it’s unavailable.link. The link elements.
JavaScript
Templates
You can customize parts of a widget’s UI using the Templates API. Each template includes anhtml function,
which you can use as a tagged template.
This function safely renders templates as HTML strings and works directly in the browser—no build step required.
For details, see Templating your UI.
The
html function is available in InstantSearch.js version 4.46.0 or later.HTML output
HTML
Customize the UI with connectPagination
If you want to create your own UI of the pagination widget, you can use connectors.
To use connectPagination, you can import it with the declaration relevant to how you installed InstantSearch.js.
JavaScript
Create a render function
This rendering function is called before the first search (init lifecycle step)
and each time results come back from Algolia (render lifecycle step).
JavaScript
If SEO is important for your search page, ensure that your custom HTML is optimized for search engines:
- Use
<a>tags withhrefattributes to allow search engine bots to follow links. - Use semantic HTML and include structured data when relevant.
Rendering options
Generates a URL for the next state.
The number is the page to generate the URL for.
JavaScript
Create and instantiate the custom widget
First, create your custom widgets using a rendering function. Then, instantiate them with parameters. You can pass two kinds of parameters:- Instance parameters. Predefined options that configure Algolia’s behavior.
- Custom parameters. Parameters you define to make the widget reusable and adaptable.
renderFunction, both instance and custom parameters are accessible through connector.widgetParams.
JavaScript