Paginate Large Sets of Algolia Data with Instantsearch JS Pagination widget

Raphael Terrier
InstructorRaphael Terrier
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 3 years 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.

egghead
egghead
~ 37 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today