How to improve folder structure ?
Unanswered
Red-throated Loon posted this in #help-forum
Red-throated LoonOP
Hello, i recently tried to make a complete folder structure to start a NextJS 15 project, so i made the following one :
- src/
- app/
- lib/
- tests/
- pages/
- public/
- prisma/
But being reviewed it was not complete/the best and needed to add folders for like : react components, interfaces and types, backend clearly separated, interactions with database... But even when i look at the documentation i just cannot understand or see how it needs to be to be correct, if you can help me it would be really great thanks 😄
- src/
- app/
- lib/
- tests/
- pages/
- public/
- prisma/
But being reviewed it was not complete/the best and needed to add folders for like : react components, interfaces and types, backend clearly separated, interactions with database... But even when i look at the documentation i just cannot understand or see how it needs to be to be correct, if you can help me it would be really great thanks 😄
15 Replies
Don’t worry about it. There’s no correct way.
All that matters is that it’s easy to understand and work with
If that folder structure works for you then go with it
The important thing is that you follow the nextjs naming, file and folder conventions
Red-throated LoonOP
Thanks for the answer but in my case some people might need to use it so i need to make it as clear as possible and kinda need these correctly implemented in my structure
@linesofcode The important thing is that you follow the nextjs naming, file and folder conventions
Red-throated LoonOP
in the documentation is there a place to see exactly how to name the folders i mentionned ?
im not really familiar with nextjs that's why it's hard to make it clear and find information efficiently
Red-throated LoonOP
and when i search i see a lot of different structures
yeah that's the base, what i don't understand is how i can add for example a folder for the interactions with my database, at what level ? src/ ? app/ ? that's the information i cannot find
and is there a convention name for it ? if yes how to find it ?
@Red-throated Loon yeah that's the base, what i don't understand is how i can add for example a folder for the interactions with my database, at what level ? src/ ? app/ ? that's the information i cannot find
You can simply create a database or db directory and inside it put:
client.ts
queries/
schemas/
or any other way that works for you!
client.ts
queries/
schemas/
or any other way that works for you!
@Losti! You can simply create a database or db directory and inside it put:
client.ts
queries/
schemas/
or any other way that works for you!
Red-throated LoonOP
thanks, and in terms of level in the structure, is there any convention ? or do i put it at the same level as src/ ? (or in src/ ?)
in src
Red-throated LoonOP
okay thanks