New to Next.Js, confused about general structure of App Router
Answered
Turkish Angora posted this in #help-forum
Turkish AngoraOP
So if I get this right, _document.tsx should serve as my overall document structure, layout.tsx should serve as my overall page structure, page.tsx should serve as individual page components?
So does each page need to be named “page.tsx�
Similarly what if I need multiple layouts? Create them as individual components inside the one layout.tsx and import them? I can’t create multiple layouts such as admin-layout.tsx or dashboard-layout.tsx?
Really seems like there needs to be more flexibility in regards to file naming?
Can I configure the path names myself in the config files to get around this?
I am someone who like very explicit naming, it helps in large projects for me.
Can I nest my files in folders as a work around instead?
So does each page need to be named “page.tsx�
Similarly what if I need multiple layouts? Create them as individual components inside the one layout.tsx and import them? I can’t create multiple layouts such as admin-layout.tsx or dashboard-layout.tsx?
Really seems like there needs to be more flexibility in regards to file naming?
Can I configure the path names myself in the config files to get around this?
I am someone who like very explicit naming, it helps in large projects for me.
Can I nest my files in folders as a work around instead?
12 Replies
Tan
_document.tsx does not exist in app router
yes, each page needs to be page.tsx within a named folder
you can put a layout within a folder and it will apply to the page of the folder and all nested folders
you can name component files whatever name you want
as long as they're not used for certain things by next.js
(like page.tsx)
Can I configure the path names myself in the config files to get around this?I don't understand what this means
Can I nest my files in folders as a work around instead?a workaround for what?
Tan
@Turkish Angora hope this helps
Answer
Turkish AngoraOP
If _document.tsx does not exist in app router what is the specific file used by next for the document? Layout.tsx?
Turkish AngoraOP
Ok thanks!