Prerendering error
I'm currently encountering an error when trying to build my application. My application is nextJS version 15 using app router:
The error I'm getting:
My code:
I saw that juliusmarminge might have gotten a similar error, but I'm not sure. Its a while ago. https://github.com/TanStack/query/pull/8383#issuecomment-2593409074
Here he commented, that adding
export const dynamic = "force-dynamic" fixed the error - It also fixed it for me. If it's the same error that I'm encountering, has there then a better solution, so I don't have to tell each file to be dynamic?1 Reply
fascinating-indigoOP•7mo ago
I think I found the solution, and it was the same error.
In my query client factory (the file that creates a QueryClient instance), I hadn't disabled error redaction on dehydration. It was as simple as adding the following, which I found on the docs:
The reason it wasn't initially disabled was because I was following the new tRPC intergration with React Query. Their documentation doesn't mention that this should be disabled when using Next.js. Would be helpful if there were some kind of info card, informing people about this.