Next.js App Router Architecture & Patterns
Best practices for structuring modern full-stack web applications using React Server Components and Next.js App Router.
Key Principles
- Default to Server Components: Keep data fetching on the server; only mark components with client directive when browser APIs, event listeners, or hooks are needed.
- Colocation of Route Segments: Structure routes using folder hierarchies with
page.tsx,layout.tsx,loading.tsx, anderror.tsx. - Mutations via Server Actions: Use server action functions for forms and state mutations with
revalidatePathandrevalidateTag.