Next.js App Router: Patterns I Reach for on Every Project
Server Components, route groups, streaming and server actions — the handful of patterns that keep my Next.js codebases fast and easy to reason about.
By Habib Ur RehmanSenior Full Stack Engineer & MVP Partner- Published
- Updated
- 8 min read

Key takeaways
- Default to Server Components and add 'use client' only where state, effects or browser APIs are needed.
- Wrap slow data in Suspense so the page shell renders immediately and widgets stream in.
- Use Server Actions for mutations, validate input on the server and revalidate affected paths.
- Keep all data access in one layer so caching, auth and testing stay simple.
The App Router changed how I structure React apps. After shipping several production projects with it, a few patterns have proven themselves again and again.

Default to Server Components
Every component is a Server Component until it needs state, effects or browser APIs. Pushing 'use client' as far down the tree as possible keeps JavaScript bundles small and lets you fetch data right where it's used.
// app/dashboard/page.tsx (Server Component)
import { getStats } from "@/lib/stats"
import { Chart } from "./chart" // 'use client' lives here only
export default async function Dashboard() {
const stats = await getStats()
return <Chart data={stats} />
}Stream slow parts with Suspense
Wrap slow data in Suspense boundaries so the shell renders instantly. Users see a useful page in milliseconds while the heavy widgets fill in.

Server Actions for mutations
For forms and simple mutations, Server Actions remove an entire layer of API boilerplate. Validate on the server, return typed results, and revalidate the paths that changed.
- Validate every input on the server, even if the client validates too.
- Return a result object instead of throwing for expected errors.
- Call revalidatePath or revalidateTag after a successful write.
Keep data access in one place
I put all queries in a small data layer (lib/ or server/) so components never talk to the database directly. It makes caching, auth checks and testing dramatically simpler. For the backend side of the same idea, see building scalable SaaS applications with Next.js and NestJS.
FAQs
Practical answers to the questions that come up most when teams adopt the App Router.
Use a Client Component only when the component needs state, effects, event handlers or browser-only APIs. Everything else should stay a Server Component to keep the JavaScript bundle small.
Yes, provided you treat them like any public endpoint: validate and authorise every request on the server, return typed results for expected errors, and never trust client-side validation alone.
Stream slow data with Suspense boundaries, fetch data inside Server Components close to where it is used, and avoid pushing large libraries into client bundles.
The usual causes are large client-side JavaScript bundles, sequential data fetches that wait on each other, unoptimized images and fonts, heavy third-party scripts, missing caching and slow database queries behind the pages. Profile first, because the bottleneck is often the data layer rather than React.
Use Lighthouse and Chrome DevTools for lab data, the useReportWebVitals hook from next/web-vitals to collect real-user Core Web Vitals, and @next/bundle-analyzer to inspect bundle size. For field data, use PageSpeed Insights or the Chrome UX Report. Compare lab and field numbers, since real devices and networks are usually slower than a developer laptop.
Use next/dynamic (or React.lazy) for heavy client components that aren't needed for the first paint, such as charts, rich-text editors, maps or modals. Avoid lazy-loading content that is visible immediately, because it delays the content users came for.
Use Server Actions for mutations triggered from your own UI, such as form submissions. Use Route Handlers when you need a public HTTP endpoint: webhooks, third-party or mobile clients, or custom response formats. Both run on the server, so validate and authorise every request in either case. For a larger example, see the SaaS architecture guide.
References
- Server and Client Components — Next.js documentation
- React Server Components — React documentation
- Server Actions and mutations — Next.js documentation
- #Next.js
- #React
- #Performance
Keep reading
SaaS & MVP
Building Scalable SaaS Applications with Next.js and NestJS
A practical architecture guide to building a multi-tenant SaaS with Next.js and NestJS: how the two fit together, how to handle auth, databases, tenancy and background jobs, and what to avoid.
- Published
- 11 min read

Cloud & DevOps
Scaling a Node.js API on GCP Without Over-Engineering
From a single Cloud Run service to a resilient, observable backend — what to add at each stage of growth, and what to skip until you need it.
- Published
- Updated
- 8 min read

SaaS & MVP
How I Ship a Production-Ready MVP in Six Weeks
A practical playbook for founders: what to cut, what to keep, and how to sequence the work so you launch fast without building a house of cards.
- Published
- Updated
- 7 min read