Next.jsMedium

What is the difference between static and dynamic rendering in the App Router?

Static rendering produces HTML and the RSC payload ahead of time, at build or revalidation, and serves it from cache. Dynamic rendering produces them per request. With Cache Components (Next.js 16) the choice is no longer per route: each route gets a static shell, and only the parts that need request data render dynamically inside <Suspense>.

Static

  • Rendered at next build or in the background on revalidation.
  • Served from a CDN, so it is fast and cheap.
  • Same output for every visitor.
  • Examples: marketing pages, docs, product pages with cached data.

Dynamic

  • Rendered on each request on the server.
  • Needed for cookies, headers, searchParams, per-user data, or values like Date.now().
  • Examples: dashboards, carts, search results.

Previous model: per route

A route was static unless something made the whole route dynamic: cookies(), headers(), searchParams, an uncached fetch, or export const dynamic = 'force-dynamic'. One cookies() call in a header could make every page dynamic.

Cache Components: per component (Partial Prerendering)

  • Static and "use cache" content goes into the static shell.
  • Request-time content streams into <Suspense> holes.
  • Next.js validates this in development and build: uncached work outside <Suspense> is flagged as a blocking route.
  • ensureStatic (16.4) can enforce that a page stays static, and instant checks that navigations show UI immediately.

How to check

next build marks routes in its output. In dev, the Next.js DevTools show route info and insights.

Code example

tsx
1// app/product/[id]/page.tsx - static shell + dynamic hole (Cache Components)
2import { Suspense } from "react";
3import { cookies } from "next/headers";
4import { cacheLife } from "next/cache";
5
6async function Details({ id }: { id: string }) {
7 "use cache"; // static: cached and prerendered
8 cacheLife("hours");
9 const p = await fetch(`https://api.example.com/products/${id}`).then((r) => r.json());
10 return <h1>{p.name}</h1>;
11}
12
13async function Recommendations() {
14 const userId = (await cookies()).get("uid")?.value; // dynamic: per request
15 const recs = await fetch(`https://api.example.com/recs?u=${userId}`).then((r) => r.json());
16 return <ul>{recs.map((r: { id: string; name: string }) => <li key={r.id}>{r.name}</li>)}</ul>;
17}
18
19export default async function Page({ params }: PageProps<"/product/[id]">) {
20 const { id } = await params;
21 return (
22 <>
23 <Details id={id} />
24 <Suspense fallback={<p>Loading recommendations…</p>}>
25 <Recommendations />
26 </Suspense>
27 </>
28 );
29}

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.

Open in study app