infiniteHits widget hits per page

I’m using InstantSearch.js and have implemented the infiniteHits widget.

Is it possible to have two different configurations for hits per page?

I’d like to initially display 20 product results and when a user clicks the ‘load more’ button, only 10 new results are shown, not 20.

In my code, this is the only place where hits per page is defined:

search.addWidgets([
  instantsearch.widgets.configure({
    hitsPerPage: 20
  }),

Hi @utxoutput,

Unfortunately the number of hits loaded is always synced with the hitsPerPage parameter. You can’t set the a different number out-of-the box. The alternative would be to build your own widget that can patch the hitsPerPage once the user clicks on the button. You can find more information about that in the documentation: https://www.algolia.com/doc/guides/building-search-ui/widgets/create-your-own-widgets/angular/#when-do-i-need-to-create-widgets

Hope that helps!

1 Like