Next.js Discord

Discord Forum

Trying to Understand Next 14

Unanswered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
I don't understand the layout.tsx, does it automatically takes page.tsx as the children prop?

23 Replies

@Ray yes it wrap your page in the children props
Nile CrocodileOP
What if I delete that, add some custom file?
Is it agnostic in that respect, or does it have to be page?
you must have the root layout at root
Nile CrocodileOP
I mean the page.tsx
https://nextjs.org/docs/app/api-reference/file-conventions
you need to follow the file conventions
or it won't work
Nile CrocodileOP
Oh oky
you can have other file inside the app folder but nextjs will ignore them unless you put them into the code
Nile CrocodileOP
So basically we kind of treat page.tsx as the body, and add other components into it
correct
and the layout.tsx persist over page change
so you can put eg navbar, sidebar in it
Nile CrocodileOP
But I also read there's something called multi layout
@Ray so you can put eg navbar, sidebar in it
Nile CrocodileOP
Seems neat
yes a route group
@Ray yes a route group
Nile CrocodileOP
So how do we specify which components are wrapped by the layout component? Like in case of multiple of layout components
we don't wrap the layout component. Instead we create multiple layout.tsx in different route group
@Ray we don't wrap the layout component. Instead we create multiple layout.tsx in different route group
Nile CrocodileOP
So there has to be atleast one layout in the root dir app
yes
Nile CrocodileOP
Or is it like each folder has to have only one layout?