-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: NextRouter was not mounted. #5475
Comments
Hi, We retrieve the initial InstantSearch state by relying on React's Here are 2 options that have similar outcome (
|
Hi @dhayab thank you for your answer! I think this solution is too "out of" Next.js. I would like, as much as possible, to rely on Next.js first class exported API. For those who may face the same issue, I succeed to give correct The only downside is that you need to do hacky things to populate |
As you found a solution, we'll close this issue, but we are aware and looking into ways we could expose the widgets without doing a render, or having a guide on how to expose all your necessary contexts in getServerState (Next doesn't really allow it), but that's tracked in other places already. Thanks for making us further aware |
Hi, @antoine-lin Could you provide an example of how you get the |
🐛 Current behavior
Hi, I would like to setup SSR for Algolia using Next.js.
I got a bug with the usage of
getServerState
fromreact-instantsearch-hooks-server
. I need to useuseRouter
inside my page but when rendering to string server side theNextRouter
context is not mounted leading to this bug:🔍 Steps to reproduce
useRouter
and use it inindex.tsx
null
on server when you console.logrouter
. In Next.js 13 the app is crashing.Live reproduction
https://codesandbox.io/s/bug-reproduction-for-algolia-ssr-with-next-js-bmcpni?file=/pages/index.tsx
💭 Expected behavior
Initial state from SSR fetch should be resolved without crashing the application.
Having to use
react-dom/server
insidegetServerSideProps
seems to not be aligned with how Vercel designed itPackage version
react-instantsearch-hooks-server 6.39.3, react-instantsearch-hooks-web 6.39.1, next 13.1.6, react 18.2.0
Operating system
macOS Ventura 13.2
Browser
Chrome Version 109.0.5414.119 (Build officiel) (arm64)
Code of Conduct
The text was updated successfully, but these errors were encountered: