Skip to content

Syncing URL with instantsearch using next.js adding one unnecessary re-route #6165

Closed Answered by dhayab
AbdelrahmanAhmed605 asked this question in Q&A
Discussion options

You must be logged in to vote

With routing enabled, you don't need to set the initialUiState as long as you navigate to the search page with the correct query parameters. Just change the route in your handleSearch() method to match what InstantSearch expects by default.

Alternatively, you can customize the query string generated and parsed by InstantSearch router by changing the state mapping: https://www.algolia.com/doc/guides/building-search-ui/going-further/routing-urls/js/#rewriting-urls-manually.

Finally, as you're using React InstantSearch with Next.js, make sure you read about our dedicated routing support for this framework and choose the relevant method related to whether you are in app or page router:

  • pages…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AbdelrahmanAhmed605
Comment options

Answer selected by AbdelrahmanAhmed605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks)
2 participants