style-components ThemeProvider not working in Next 13 Server Component
Unanswered
Honey bee posted this in #help-forum
Honey beeOP
I'm trying to wrap ThemeProvider around my Page Component. I'd like to render it on the server and still be able to use my provided Theme Configuration in the server component. When trying to do that I get the error saying that I cannot use Context API inside server component. What I'm interested in is how to correctly solve this issue?
2 Replies
@Honey bee I'm trying to wrap ThemeProvider around my Page Component. I'd like to render it on the server and still be able to use my provided Theme Configuration in the server component. When trying to do that I get the error saying that I cannot use Context API inside server component. What I'm interested in is how to correctly solve this issue?
Spectacled Caiman
You can't use Styled components "anymore". It only works on client component. I switched to CSS Modules
you need to wrap the context providers in a client component then use it in the
layout.tsx file, the docs have an example for this: https://nextjs.org/docs/getting-started/react-essentials#rendering-third-party-context-providers-in-server-components