🎁

12 Days of Baddass Courses sale! Get instant access to the entire egghead library of courses and lessons for 58% off.

Runs out in:
11 : 17 : 29 : 04
1×
Become a member
to unlock all features
Autoplay

    Paginate Large Sets of Algolia Data with Instantsearch JS Pagination widget

    Raphael TerrierRaphael Terrier
    algoliaAlgolia

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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?

    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.

    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.

    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.