Replies: 2 comments 4 replies
-
The next hooks example already has URL Synchronisation: https://github.com/algolia/react-instantsearch/blob/9b096a83120396639d490000d9803f2a5bd55fb3/examples/hooks-next/pages/index.tsx#L51-L61 Is there something missing in that example for what you want to create? If you pass routing you don't need to manually listen for url changes or set ui state, that's all happening behind the scenes. The reason the next router isn't used in that example is because in findResultsState we need to know the URL too, but that's rendered outside of the Next context. |
Beta Was this translation helpful? Give feedback.
-
Hi @wenche 👋 , thanks for your feedback. There appears to be a conflict indeed between Next router and the history router we have in InstantSearch. I've logged an issue to look into it in more depth. In the meantime, you can achieve what you want by leveraging Next I've set up a minimal sandbox you can access here: https://codesandbox.io/s/mystifying-pine-qjfhh1?file=/pages/index.tsx. Let me know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
-
👋 Hello!
We are implementing a search on our new web page using react-instantsearch-hooks and we are facing some troubles with understanding exactly how the URL synchronisation will work with new props for
In previous project we have used
searchState
andonSearchStateChange
from the original React library together withnext/router
and that works fine.In the new version, this is changed in favour of
routing
,initialUiState
andonStateChanged
. I notice that only therouting
param mentions URL in the updated docs, andinitialUiState
andonStateChanged
don't mention this as a thing you could use these parameters to solve unlike the non-hooks version. (And the uiState object is pretty more complex than the originalsearchState
because of the indexName)I don't quite understand the recommended way of doing this with the new parameters. Mainly because I don't understand how and if we can use the
routing
with Next.js' router instead of the internal Algolia one and the "API" of the routing object is not very well documented.I would love to see the Next.js example repo for the hooks version to be updated with an example of URL synchronisation. 👍
Beta Was this translation helpful? Give feedback.
All reactions