How can we control the number of hits when in desktop/mobile

Hi, we have a challenge with the requirement as well as with Algolia implementation of search.

As per the requirement in the UI, when the our web page is accessed through desktop, we need to show 8 hits, and when access through mobile, we only need to show 4 hits. We’re using javascript instantsearchjs plugin.

Is there a way we can do this? Thank you!

Hello,

A quick workaround to this issue would be, on your side, to detect if the user is browsing on desktop or mobile.
example: https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser

This way, it would be easy when instantiating instantsearch, to use on condition on the option hitsPerPage: in your case, 4 or 8.

Let me know if this helps,

Hi @baptiste.coquelle

Thank you for this information, now that I knew I have to do this on my end, I placed a condition and based it on the window width to be more accurate, because tablets have bigger screens and usually are considered as mobile device.