Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Paginate Large Sets of Algolia Data with Instantsearch JS Pagination widget


    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.



    Become a Member to view code

    You must be a Pro 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
    orLog In




    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.