Error: Switched to client rendering because the server rendering errored: UNAUTHORIZED
What could be the possible reason for this error?
This is how my NextJS structure looks when using tRPC.
- /app/settings/page.tsx
- /components/settings/view/categories-view.tesx
- /components/settings/section/categories-section.tsx

14 Replies
Cookies aren’t being properly passed on when fetching in SSR, still a restriction with useSuspenseQuery.
when I tried to comment back the
shouldDehydrateQuery
I'm not getting that error, but the continuously sending a request is my problem when I'm not logged in and try to refresh the page, It will always sending a request on the api even I have a Suspense
and ErrorBoundary
, so on the network tab on chrome dev tools I have a thousands request
Yeah, you shouldn’t retry on server
I use this to prevent retries on server render:
so the
shouldDehydrateQuery
should be enabled? and I will only add this to prevent the continuously sending request?here's the sample of the error that I'm talking about continuously sending request

when the
shouldDehydrateQuery
is enabled
even I have Suspense
and ErrorBoundary
You should leave the shouldDehydrateQuery as is
Keep whatever the defaults were given by trpc
Okay thank you, I will try your code.
And actually, the guide I followed is this tRPG Tanstack React Query (Server Components).
Yeah, they sometimes do not provide good defaults
your code is missing the variable of
isServer
where I can get this
can you provide the full code? @BeBoRE
React query gives you this
oohh I see, thank you, I'm new to trpc and react query, I just following the youtube clone by @CodeWithAntonio