#Can't have access to file system module while trying server components
28 messages · Page 1 of 1 (latest)
You can't use server components in the pages directory @celest halo
I read that pages in nextjs are considered as server component
Well.... how should I use server components?
The app directory
if your layout is a client component, all pages are client components too
i think
so check if that is the case
Thanks
Is this true? Do you have a resource that says this is true?
might not be true
wouldnt make sense imo cuz then server components would become obsolete and they say in docs that u can mix and match them
according to the current documentation, the root layout can't be a client component
where does it say that
because I was using it in my testing
Looking at this
thats weird
I used it as a client in my build and dev
and i was never getting any errors for it
i'm not sure if the documentation is correct there
because what I read in my link was:
This pattern is already applied in layouts and pages with the children prop so you don't have to create an additional wrapper component.
So from that I assumed its okay if layout is a client component as long as ServerComponents are children of it
Then I also just found
Layouts are Server Components by default but can be set to a Client Component.
But maybe the wording is wrong here and means specifcally non root layout components
If this is the case then, If im using a Session and ThemeProvider I need to put those in their own client components
to then put on the layout