Lesson 2 of 27Foundations
Rendering Strategies
Tell CSR, SSR, SSG, ISR, streaming and partial prerendering apart, and pick the right one for each page.
"What is the difference between SSR, SSG and ISR?" is one of the most common Next.js interview questions, and the answer decides real things: how fast a page loads, how fresh its data is, and how much your servers cost. The trick is that every strategy is an answer to two questions: where does the HTML get made, and when?
The two questions
- Where: in the browser (client) or on a server.
- When: at build time, at request time, or at build time and then refreshed later.
Every acronym below is a combination of those answers. Keep the waiting user in mind: the time until the first byte arrives (TTFB, time to first byte) and the time until real content is on screen.
Run this simulation. Each strategy is a list of steps with rough costs in milliseconds.
Press Run (⌘ Enter) to see what happens.SSG wins on speed, but its HTML was made at build time. That is fine for a blog post and wrong for a shopping cart. The rest of this lesson is about that trade-off.
The four classic strategies
Client-side rendering. The server sends a shell and a bundle; the browser renders and fetches. Fast to host (static files), slow to first content, weak for SEO. In Next.js you get this for parts of a page by fetching inside a Client Component with useEffect or a library like SWR or TanStack Query.
GET /dashboard
Server-side rendering. On every request, the server fetches data and renders HTML. Always fresh, good for SEO, but every visitor waits for the slowest query, and every request costs server time. In the Pages Router this was getServerSideProps. In the App Router it is any component that reads request data such as cookies().
GET /account
Static site generation. HTML is rendered once, at next build, and served from a CDN. The fastest possible response, but the content is frozen until the next deploy. Great for docs, marketing pages and blog posts. generateStaticParams tells Next.js which dynamic URLs (like /blog/[slug]) to build.
next build renders /pricing
Incremental Static Regeneration. Static, but with an expiry. After the revalidate time passes, the next visitor still gets the old page instantly, and Next.js rebuilds it in the background. This pattern is called stale-while-revalidate. You can also trigger a rebuild on demand when data changes.
GET /products (age 90s)
Here is the ISR rule as code. The visitor who triggers the rebuild still gets the old version.
Press Run (⌘ Enter) to see what happens.What does this print?
let version = 1;
let builtAt = 0;
const revalidate = 60;
for (const t of [30, 90, 100]) {
console.log(version);
if (t - builtAt >= revalidate) { version++; builtAt = t; }
}Streaming: stop waiting for the slowest query
SSR has a weakness: one slow query holds back the whole page. Streaming fixes it. The server sends the HTML it can render right away, with placeholders, and keeps the connection open. As each slow part finishes, React sends it down the same response and swaps it into place.
In React the placeholder is a <Suspense> boundary: a component that shows a fallback while anything inside it is still loading. You can feel the effect in the browser with React 19's use() hook, which suspends until a Promise resolves.
The title and price show instantly; reviews fill in later. In Next.js the same thing happens on the server, over a single HTTP response.
GET /product/42
Partial prerendering and Cache Components (Next.js 16)
Most real pages are mixed: the layout and product details are the same for everyone, the cart badge depends on a cookie. Next.js 16 stops asking you to pick one mode per page. With Cache Components turned on (cacheComponents: true in next.config.ts, which new create-next-app projects enable by default), every page follows one model called Partial Prerendering (PPR):
- At build time, Next.js renders the page and keeps everything it can: plain markup, and anything marked with the
"use cache"directive. - Anything that needs the request (cookies, headers, search params, uncached data) must sit inside a
<Suspense>boundary. Its fallback goes into the prerendered HTML. - The result is a static shell served instantly from a CDN, with holes that stream in at request time.
Put the life of a partially prerendered page in order.
- Tap the steps below in the right order.
If a component reads request data without a Suspense boundary, next build stops with an error that offers three fixes: stream it (wrap it in Suspense), cache it ("use cache"), or explicitly allow the route to block. The build output marks each route: ○ fully static, ◐ partial prerender (shell plus streamed holes), ƒ rendered entirely on demand. You will write use cache yourself in the data fetching lesson.
What about the previous model?
Apps without cacheComponents use the model from Next.js 13 to 15: each route is either fully static or fully dynamic. A route becomes dynamic as soon as anything in it reads cookies(), headers() or searchParams, and time-based ISR is configured with export const revalidate = 60 in the page file. You will see this in many existing codebases. The mental model (static where possible, stream what is not) carries over.
Choosing a strategy
| Strategy | HTML made | Freshness | Speed | Typical page |
|---|---|---|---|---|
| CSR | In the browser | Live | Slow first paint | Highly interactive widgets behind login |
| SSR | Server, every request | Live | Waits on data | Account pages, search results |
| SSG | Build time | Until next deploy | Fastest | Docs, marketing, blog posts |
| ISR | Build, then background refresh | Bounded staleness | Fast | Product catalogs, news listings |
| Streaming | Server, in chunks | Live | Fast first byte | Pages with one slow section |
| PPR | Static shell + streamed holes | Mixed per component | Fast shell, live holes | Most pages in a Next.js 16 app |
Match each page to the strategy that fits best.
Static, partial, or dynamic?
With Cache Components on, next build prints a symbol next to every route: ○ static, ◐ partial prerender, ƒ dynamic. Write classifyRoute(parts) that predicts it.
Each part of the page is one of:
"static": plain JSX or data known at build time"cached": a component or function with"use cache"and a normal lifetime"suspended": runtime data (cookies, headers, uncached fetch) inside a<Suspense>boundary"blocking": runtime data with no<Suspense>boundary above it
Return "dynamic" if any part is blocking, "partial" if any part is suspended, otherwise "static".
["static", "cached"] → "static"
["static", "suspended"] → "partial"
["cached", "suspended", "blocking"] → "dynamic"Simulate stale-while-revalidate
Incremental Static Regeneration serves the cached page and refreshes it in the background. Simulate it.
Version 1 of a page is built at time 0. Requests arrive at the times in times (seconds, ascending). For each request:
- Serve the current version.
- If
time - builtAt >= revalidate, the page is stale: a background rebuild finishes right after the response, so the version goes up by one andbuiltAtbecomes this request's time.
Return the version each request was served.
revalidate = 60, times = [10, 70, 75, 200] → [1, 1, 2, 2]The request at 70 still gets version 1 (stale), but triggers version 2 for everyone after it.
- SSR
- Server-side rendering: HTML is rendered on the server for every request. Fresh, but each visitor waits for the data.
- SSG
- Static site generation: HTML is rendered once at build time and served from a CDN.
- ISR
- Incremental Static Regeneration: static pages that are rebuilt in the background after a revalidate time or on demand.
- stale-while-revalidate
- Serve the cached (stale) version immediately and refresh it in the background for the next visitor.
- streaming
- Sending HTML in chunks over one response, so fast parts appear while slow parts are still rendering behind Suspense fallbacks.
- partial prerendering (PPR)
- Next.js 16's default with Cache Components: a prerendered static shell with request-time parts streamed into Suspense holes.