Skip to content
RenderingChapter 12 / 34Intermediate5 min read

Rendering Strategies: SSR, SSG, ISR

Next.js SSR SSG ISR: the difference between static, dynamic and incremental rendering, and how to write them with use cache and cacheLife in Next.js 16 Cache Components.

On this page

1. What are rendering strategies?

StrategyFull nameWhen the HTML is created
SSGStatic Site GenerationAt build time, once
SSRServer-Side RenderingOn every request
ISRIncremental Static RegenerationAt build time, then again after some time or on an event
PPRPartial PrerenderingThe static shell at build time, the dynamic parts on request

In Next.js 16 these are less like separate "modes" and more like choices inside a single page. When Cache Components is on, each component says for itself whether it is cached or dynamic.

2. Why does it matter?

Every page has different needs. An "About us" page does not change daily, a cart is different for every user, and a product price changes once an hour.

Wrong strategyRight strategy
About page rendered on every request, extra load on the serverSSG, instant from the CDN
Cart made static, everyone sees the same cartSSR, a separate cart for each user
Product price fixed at build time and shows stale dataISR, fresh every hour
Whole page dynamic because of one widgetPPR, only the widget is dynamic

3. Where is it used?

PageStrategy
Landing page, docs, blog postSSG
Dashboard, cart, profileSSR (request time)
Product listing, news feedISR (cacheLife("hours"))
Product page with a "for you" sectionPPR (static shell + dynamic widget)

4. How does it work?

Next.js 16 has two models:

cacheComponents off (classic)cacheComponents: true (new)
Route is static by default if there is no dynamic APIData is dynamic by default
cookies or searchParams make the whole route dynamicOnly the part inside Suspense is dynamic
ISR with export const revalidate = 60ISR with use cache + cacheLife
export const dynamic force-dynamicNo config needed
next.revalidate option of fetchuse cache in a function
A page with Cache Components
Page renders at build time
The use cache part goes into the static shell
The dynamic part inside Suspense gets a fallback
A request arrives, the static shell is sent immediately
The dynamic part renders on the server and streams in

In this model, the dynamic, revalidate and fetchCache route segment configs cause an error. "use cache" and cacheLife replace them.

5. Code example

All three examples below use cacheComponents: true.

SSG: the whole page cached

tsx
import { cacheLife } from "next/cache";

export default async function AboutPage() {
  "use cache";
  cacheLife("max");
  const team = await fetch("https://api.example.com/team").then((r) => r.json());
  return <h1>Our team: {team.length} people</h1>;
}

ISR: refresh every hour

tsx
import { cacheLife, cacheTag } from "next/cache";

async function getProducts() {
  "use cache";
  cacheLife("hours");
  cacheTag("products");
  const res = await fetch("https://api.example.com/products");
  return res.json();
}

export default async function ProductsPage() {
  const products = await getProducts();
  return <p>{products.length} products</p>;
}

SSR / PPR: the user-specific part at request time

tsx
import { Suspense } from "react";
import { cookies } from "next/headers";

async function CartCount() {
  const cartId = (await cookies()).get("cart")?.value;
  const res = await fetch(`https://api.example.com/cart/${cartId}`);
  const cart = await res.json();
  return <span>{cart.items.length} items</span>;
}

export default function ShopHeader() {
  return (
    <header>
      <h1>ZnShop</h1>
      <Suspense fallback={<span>...</span>}>
        <CartCount />
      </Suspense>
    </header>
  );
}

How does the code work?

PartMeaning
"use cache" on the pageThe whole page is cached and prerendered at build time (SSG)
cacheLife("max")A very long lifetime, revalidated in the background
cacheLife("hours")Fresh every hour (like ISR)
cacheTag("products")Lets you refresh on demand later with revalidateTag or updateTag
cookies() inside SuspenseOnly this part runs at request time (SSR)
The rest of the headerIn the static shell (PPR)

Interview tip

"When do you use SSR and when SSG?" Use SSR for data that changes per user or per request, SSG for data that is the same for everyone and changes rarely, and ISR for something in between. In Next.js 16 this decision is made at the component level instead of the page level.

6. Common mistakes

Mistake: Turning on cacheComponents and keeping export const revalidate

Why? With Cache Components, the dynamic, revalidate and fetchCache configs cause errors.

Better: Use use cache and cacheLife, and if revalidate is 0, simply remove the config.

Mistake: Making the whole page dynamic because of one cookie

Why? You lose the benefit of the static shell and the whole page renders on every request.

Better: Move the component that reads the cookie into its own file and wrap it in Suspense.

Mistake: Reading cookies or headers inside use cache

Why? A cached result is shared between all users, so request data is not allowed inside.

Better: Read request data outside and pass the needed value to the cached function as an argument.

7. What to learn before and after

Final quick revision

PointDetail
SSGHTML at build time, "use cache" + cacheLife("max")
SSROn request, dynamic data inside Suspense
ISRcacheLife("hours") or the classic revalidate
PPRStatic shell + streamed dynamic parts
Next.js 16The decision is at component level, with cacheComponents: true