Next.js Discord

Discord Forum

Passing Theme Context into a Sever Side Component

Unanswered
Lilac posted this in #help-forum
Open in Discord
Avatar
LilacOP
The docs say we should wrap a context provider in a client component and then place it in the root.

But what if we need to pass this context like a theme or user auth info down to server components as well?
Since server components cannot use context

8 Replies

Avatar
Northern Wheatear
Actually you can do this
This is an example
Image
Using suspense is optional there
Image
This is the datawrapper component which gets data from db and passes it to a context provider
Then the AppLayout in my RootLayout contains the rest of the layout which needs the data from context...
Avatar
LilacOP
But only client components can access context