File Structure
Unanswered
American black bear posted this in #help-forum
American black bearOP
i have a nextjs project it has 3 main but separate pages (there is no overlap between them )
i currently have it like this
App
Components
- A components
- B components
- C components
Lib
- A lib
- B lib
- C lib
A
- page
B
- page
C
- page
i hate this approach and would prefer
A
- page
- A Lib
-A components
etc but is this viable ?
i currently have it like this
App
Components
- A components
- B components
- C components
Lib
- A lib
- B lib
- C lib
A
- page
B
- page
C
- page
i hate this approach and would prefer
A
- page
- A Lib
-A components
etc but is this viable ?
6 Replies
Saint Hubert Jura Hound
its very hard to understand what kind of file structure u mean for both examples.
but i personally just put my components on the page theyre used on, unless theyre shared between multiple pages, then i put them in a shared components directory in which u can have separate sbudirectories for routes in case u have a lot of components
but i personally just put my components on the page theyre used on, unless theyre shared between multiple pages, then i put them in a shared components directory in which u can have separate sbudirectories for routes in case u have a lot of components
dont see why youd need separate lib folders
@Saint Hubert Jura Hound its very hard to understand what kind of file structure u mean for both examples.
but i personally just put my components on the page theyre used on, unless theyre shared between multiple pages, then i put them in a shared components directory in which u can have separate sbudirectories for routes in case u have a lot of components
American black bearOP
yeah ill follow that approach i was concerned if i did
dashboard
- components
- A
page.tsx
layout.tsx
if a user goes to /dashboard/components/A the component would show but if it doesnt have a page it wont thankfully
dashboard
- components
- A
page.tsx
layout.tsx
if a user goes to /dashboard/components/A the component would show but if it doesnt have a page it wont thankfully
Saint Hubert Jura Hound
oh yea no it wont. only these file/folder names have an effect on ur app:
https://nextjs.org/docs/app/api-reference/file-conventions
https://nextjs.org/docs/app/api-reference/file-conventions
American black bearOP
thanks for the help