Next.js Discord

Discord Forum

Architecture for large projects

Spot-billed Duck posted this in #help-forum
Open in Discord
Spot-billed DuckOP
Hello, excuse me for disturbing you,
I like to set up the best possible architecture for Next.js in order to combine backend and front-end for a rather big project.
I would like to have your opinions on this and resources to guide me in this operation.

I used nextjs before, but it became a bit messy...

8 Replies

Spot-billed DuckOP
Firstly, you aren't disturbing anyone by posting here.

Secondly, Since nextjs is moving towards server components and actions, some mix and match between the frontend and backend is inevitable.

On the other hand i think a simple structure like this should suffice for most applications of varying sizes:

- components/
- actions/
- ... Rest of your app
You can move the first two folders anywhere if you need more separation and you can use Route Groups to your advantage as well.
Eric Burel
Hi, not enough information to answer you, big can mean anything
Therefore the first step would be: clarify your requirements. Is you app big in number of users ? Pages ? Parameter combination for dynamic pages ? Team size ? Do you have a separate backend, multiple teams ? Many interactive components ? Complex data ? Lots of interactivity, and interactive data fetching ?
You can take a look at the real life codebase of the State of JS survey:
you'd be interested in studying existing templates too and frameworks built on top of Next eg Blitz, Taxonomy...
Spot-billed DuckOP
Hi, sorry for the late response, i'll check that 🙂
actions for server actions? or this is like the api folder?