JS Guide
HomeQuestionsTopicsCompaniesResources
BookmarksSearch

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeTopicsnextjsRendering Strategies
PrevNext
nextjs
advanced
12 min read

Rendering Strategies

caching
isr
nextjs
performance
rendering
server-components
ssg
ssr
static-generation
streaming

Next.js supports four rendering strategies — Static (SSG) generates HTML at build time for fastest delivery, Dynamic (SSR) renders per request for fresh data, ISR revalidates static pages on a timer, and Streaming sends HTML progressively with Suspense — the App Router automatically determines the strategy based on your code.

Key Points

1Static Rendering (SSG)

HTML generated at build time, served from CDN — fastest strategy. Default when no dynamic functions are used. Use generateStaticParams for dynamic routes.

2Dynamic Rendering (SSR)

HTML generated per request — always fresh data. Triggered automatically by cookies(), headers(), searchParams, or cache: 'no-store'.

3ISR

Static pages that revalidate after a time interval — stale-while-revalidate pattern. Combines static speed with periodic data freshness.

4Streaming

Progressive HTML delivery via Suspense boundaries — static shell renders immediately, slow data streams in independently.

What You'll Learn

  • Explain the four rendering strategies (Static, Dynamic, ISR, Streaming) and when each is used
  • Know which functions make a route dynamic vs static
  • Implement ISR with revalidation for content that changes periodically
  • Use Suspense boundaries to enable streaming for progressive page loading

Deep Dive

Next.js determines how and when to render each page. Understanding rendering strategies is essential for balancing performance (speed) with freshness (up-to-date data).

Static Rendering (SSG)

HTML is generated at build time and served from a CDN. This is the fastest rendering strategy — the server does zero work per request.

JSX
// This page is static by default (no dynamic functions)
async function BlogList() {
  const posts = await fetch('https://api.example.com/posts',
    { cache: 'force-cache' }
  );
  return <PostList posts={await posts.json()} />;
}

Static pages are pre-built during next build. They're ideal for content that doesn't change per user or per request: blog posts, documentation, marketing pages, product listings.

For dynamic routes (/blog/[slug]), use generateStaticParams to tell Next.js which pages to pre-render:

JavaScript
export async function generateStaticParams() {
  const posts = await getPosts();
  return posts.map(post => ({ slug: post.slug }));
}

Dynamic Rendering (SSR)

HTML is generated on the server for each request. The page always has fresh data but is slower than static because the server must render on every request.

A route becomes dynamic when it uses any dynamic function:

  • cookies() — reads request cookies
  • headers() — reads request headers
  • searchParams — reads URL query parameters
  • fetch() with cache: 'no-store'

Next.js automatically detects these and switches to dynamic rendering — you don't need to configure it.

Incremental Static Regeneration (ISR)

ISR combines static performance with periodic data freshness. Pages are statically generated but revalidate after a time interval:

JavaScript
// Page-level: revalidate every hour
export const revalidate = 3600;
 
// Or per-fetch:
fetch(url, { next: { revalidate: 3600 } });

How ISR works:

  1. First request: serves the static page (built during next build)
  2. After revalidation period: next request triggers a background regeneration
  3. Stale page is served immediately while the new version is built
  4. Once regeneration completes, subsequent requests get the fresh page

This is the stale-while-revalidate pattern — users never wait for regeneration.

Streaming

Streaming sends HTML progressively as parts of the page become ready, instead of waiting for everything:

HTML
import { Suspense } from 'react';
 
async function Dashboard() {
  return (
    <>
      <Header />  {/* Immediate */}
      <Suspense fallback={<ChartSkeleton />}>
        <SlowChart />  {/* Streams when ready */}
      </Suspense>
      <Suspense fallback={<TableSkeleton />}>
        <SlowTable />  {/* Streams independently */}
      </Suspense>
    </>
  );
}

Each Suspense boundary streams independently. The static shell renders immediately, dynamic parts fill in as they resolve. This dramatically improves Time to First Byte (TTFB) and perceived performance.

Choosing a Strategy

Next.js makes this decision automatically based on your code:

  • No dynamic functions → Static (fastest, cached at CDN)
  • revalidate export or next.revalidate → ISR (static with periodic refresh)
  • Dynamic functions (cookies, headers, searchParams, no-store) → Dynamic (fresh per request)
  • Suspense boundaries → Streaming (progressive delivery)

The decision tree: Can the page be pre-rendered ahead of time? → Static/ISR. Does it need per-request data (user session, real-time)? → Dynamic. Can parts load independently? → Add Streaming.

Pages Router Comparison

  • getStaticProps → Static rendering (default in App Router)
  • getServerSideProps → Dynamic rendering (use dynamic functions)
  • getStaticProps + revalidate → ISR (use export const revalidate)
  • getStaticPaths → generateStaticParams

Key Interview Distinction

Static (SSG) renders at build time — fastest, served from CDN. Dynamic (SSR) renders per request — always fresh. ISR revalidates static pages on a timer — stale-while-revalidate. Streaming sends HTML progressively via Suspense. Next.js automatically determines the strategy based on whether you use dynamic functions (cookies, headers, searchParams, no-store).

Fun Fact

ISR was invented by the Next.js team in 2020 and was considered a breakthrough in the Jamstack world. Before ISR, static sites had to rebuild entirely when content changed — a blog with 10,000 pages would need to rebuild all of them for one post update. ISR made it possible to regenerate individual pages on demand, combining CDN-level performance with CMS-level content management.

Learn These First

Next.js Fundamentals

beginner

Server & Client Components

intermediate

Continue Learning

Caching & Revalidation

advanced

Data Fetching

intermediate

Performance Optimization

advanced

Practice What You Learned

What's the difference between SSR and SSG in Next.js?
junior
rendering
SSG (Static Site Generation) generates HTML at build time for fast, cacheable pages; SSR (Server-Side Rendering) generates HTML on each request for dynamic, real-time content.
Explain the different rendering strategies in Next.js (SSR, SSG, ISR) and when to use each approach.
senior
rendering
Next.js offers multiple rendering strategies: Static Site Generation (SSG) for build-time rendering, Server-Side Rendering (SSR) for per-request rendering, Incremental Static Regeneration (ISR) for static pages with background revalidation, and hybrid approaches that mix strategies per route based on content requirements.
Previous
Performance Optimization
Next
File-Based Routing
PrevNext