Paginate Large Sets of Algolia Data with Instantsearch JS Pagination widget

Raphael Terrier
InstructorRaphael Terrier

Share this video with your friends

Send Tweet
Published 4 years ago
Updated a year ago

When you have a large result set for a specific query and usually not displaying more than a few dozen simultaneously. Pagination is a popular widget that allows the user to switch between pages of the results.

Instructor: [00:00] Let's type in a random short query that will match with a lot of results, DO, for example. By default, each query returns the best 20 hits. How can we access the following ones?

[00:12] That's what pagination is here for. Thankfully, the JSON response comes with everything necessary to paginate. With the pagination widget, you can add that functionality without any configuration.

[00:26] In the HTML page, we add a div container in our right column, just below the hits. We give it an ID of pagination. In our app.js file, we add the widget, same as always. Search, add widget, instantsearch, widgets, and pagination.

[00:45] Then we simply provide the container to target, the ID pagination. That's it. Refreshing the page and scrolling down to the bottom, we now have our pagination widget, allowing us to access the results way further in the set.