Won't createContext() make every child component client sided?
Answered
Savannah posted this in #help-forum
SavannahOP
I'm new to NextJS and SSR is a pretty unknown thing for me right now. I'm creating auth for my app and right now I need to wrap every project component in context provider. I cannot create the provider without using "use client". Won't it make every child component client sided?
Answered by Rafael Almeida
the solution is to create the context provider on its own file using
as explained in this doc page, a server component rendered by the
'use client' and wrap the app with it: https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#using-context-providersas explained in this doc page, a server component rendered by the
children of a client component does not change to be a client component, so the rest of the app continue being considered as server components2 Replies
the solution is to create the context provider on its own file using
as explained in this doc page, a server component rendered by the
'use client' and wrap the app with it: https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#using-context-providersas explained in this doc page, a server component rendered by the
children of a client component does not change to be a client component, so the rest of the app continue being considered as server componentsAnswer
SavannahOP
Oh, I see! Thanks, this helps