Next.js Discord

Discord Forum

What's the best practice to clearly separate client and server side?

Unanswered
Atlantic herring posted this in #help-forum
Open in Discord
Atlantic herringOP
What's the best practice to clearly separate client and server side? Is there maybe a recommended project architecture/structure?

1 Reply

It clearly depends on the project and the requirements of it. It’s an opinionated question but Nexj.js recommends a couple ways to organize the [folder structure](https://nextjs.org/docs/app/getting-started/project-structure#organizing-your-project). That said, I like to keep page.tsx and layout.tsx Server Components (default) and create a page.client.tsx file where I collocate all the Client Componenda that my page will need. I do this at every route segment level. You could also add a _components folder per route level and collocate your client components there, up to you.

At the end, no matter what you decide to follow , they recommend to stick to server components whenever possible, and add client components granularly when needed.