#Can't have access to file system module while trying server components

28 messages · Page 1 of 1 (latest)

celest halo
#

Hi
I'm working with server components. You can see the code and the error in screenshots below. I'm using Message component into a Page

dense berry
#

You can't use server components in the pages directory @celest halo

celest halo
dense berry
#

The app directory

steep cosmos
#

if your layout is a client component, all pages are client components too

#

i think

#

so check if that is the case

hidden verge
steep cosmos
#

might not be true

hidden verge
#

wouldnt make sense imo cuz then server components would become obsolete and they say in docs that u can mix and match them

steep cosmos
#

according to the current documentation, the root layout can't be a client component

hidden verge
#

where does it say that

#

because I was using it in my testing

#

Looking at this

hidden verge
#

thats weird

#

I used it as a client in my build and dev

#

and i was never getting any errors for it

steep cosmos
#

i'm not sure if the documentation is correct there

hidden verge
#

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