How can I stop React InstantSearch refinements/pagination from scrolling to the top?

Hey There,

I’ve created a search page modeled after Algolia’s home page search page. It’s multi-index and each section has pagination. When I scroll down and pagination one of the index’s results, it resets the scroll position to the top of the screen.

I noticed that Algolia’s home page search does the same thing.

Similarly, when using any dynamic widgets to toggle facets, it also scrolls to the top of the page.

Is it possible to disable this feature?


Update: This is a Next.js issue and nothing to do with Algolia,

The answer lies in Next.js’ router, for anyone else wondering. In my case, I’m using router.replace from useRouter to manually update the URL on a search state change.

async function navigate(newCurrency) {
    pathname: router.pathname,
    query: { ...router.query, currency: newCurrency.value },
  }, undefined, { scroll: false }); // scroll - false is needed here