Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Project structure · Frontend

Next.js (App Router) project structure

Opens with credits

For React developers building a real web front end with Next.js: a shop dashboard with public pages, sign-in, orders and products, talking to a separate backend API. The app folder holds routes only, product code lives in feature folders, server-only code sits in src/server, and the browser side gets a proper React setup: providers, TanStack Query, forms with React Hook Form and Zod, and tests from unit to end-to-end.

Curated by Tauseef FayyazIntermediate236 files and foldersNext.js 16.4, React 19.3, TypeScript 5Checked October 2026
Explore the filesPick any file to see what it is, why it exists and when you add it.

How it grows

Each stage opens the explorer there

  1. 1Day 1What the scaffold and your first hour give you26 files and folders
  2. 2GrowingWhat a real app with features and tests adds+129 files and folders
  3. ProductionWhat running it for real users adds+36 files and foldersOpens with credits
  4. ExpertWhat a team needs to keep it healthy for years+45 files and foldersOpens with credits

How it is organised

  • The app folder is for routing: pages, layouts, loading, error and not-found files, route handlers. Product code lives outside it in src/features, src/components and src/lib.
  • Group product code by feature (features/orders, features/products) rather than by file type. A feature owns its components, hooks, queries, actions, schema and tests, so one change touches one folder. Features never import each other; shared code moves to components or lib.
  • Server first: components are Server Components unless they need state, effects or browser APIs. Add "use client" only to the small leaf that needs it. Wrapping the tree in a client providers.tsx does not turn its children into client code.
  • Two homes for non-UI code: src/server holds server-only modules (secrets, the backend client, the session) and each starts with import "server-only"; src/lib holds code that is safe in the browser. The build fails if a Client Component imports src/server.
  • Server state comes from the backend: Server Components fetch the first render, TanStack Query handles live and interactive data in the browser. Zustand is only for small UI state such as a collapsed sidebar, never for copies of server data.
  • Route groups (marketing), (auth) and (app) give each part of the site its own layout without changing the URL.
  • Tests grow in layers: Vitest for rules and components at Growing, Playwright journeys at Production, then contract, visual, accessibility and load tests when a team and real traffic justify them.
  • Next.js does not force a layout. The docs show several valid strategies; this tree keeps code under src/ (the --src-dir flag) so the root holds only configuration, the same as the full stack tree.

At the top of the project

Open one in the explorer for the full story

Learn more on Sefism

Roadmaps, cheat sheets and projects that go with Next.js (App Router).

See 10 more
Checked against 21 official sources, October 2026. If something has changed, the docs win.Show sources

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com