Next.js Discord

Discord Forum

Error: Switched to client rendering when using Suspense

Unanswered
New Guinea Freshwater Crocodile posted this in #help-forum
Open in Discord
New Guinea Freshwater CrocodileOP
Hi everyone!

I'm seeing this error:
Error: Switched to client rendering because the server rendering errored:

When using a Suspense boundary to wait a server component that fetchs data and passes it to a client component.

if I remove the Suspense, I don't see it anymore but obviously this is not an option. It looks like it's trying to render the client components on the server? also, I'm using "use client" in these as well.

Not quite sure what I'm doing wrong.

1 Reply

New Guinea Freshwater CrocodileOP
I ended up using Suspense around the client components while using the “use” hook inside those, passing the Promises from Server Component via props. This is a recommended way to fetch data, so not quite sure if the “patter” of suspending server components that contains clients components is something that I should avoid…