Medium15 minNext.js Fundamentals
UpdatedAug 3, 2026
Edit

Next.js Rendering Strategies (SSR, SSG, ISR)

CONCEPTS:Next.js Rendering Strategies

Question Variations

  • "What is the difference between `getStaticProps` and `getServerSideProps`?"
  • "How does ISR work in Next.js?"
  • "When would you use SSR over SSG?"
  • "How does data fetching change between the Pages Router and the App Router?"

Why This Is Asked

Understanding the difference between Static Site Generation (SSG), Server-Side Rendering (SSR), and Incremental Static Regeneration (ISR) is fundamental to building performant and scalable Next.js applications. Interviewers want to see if you can choose the right strategy for a given set of requirements, balancing performance, SEO, and data freshness.

Key Concepts

  • SSG (Static Site Generation): Pre-rendering at build time.
  • SSR (Server-Side Rendering): Pre-rendering on every request.
  • ISR (Incremental Static Regeneration): Updating static content after build time without rebuilding the whole site.
  • Client-Side Rendering (CSR): Rendering in the browser (standard React behavior).
  • Hybrid Rendering: Mixing different strategies within the same application.

Question Variations

  • “What is the difference between getStaticProps and getServerSideProps?”
  • “How does ISR work in Next.js?”
  • “When would you use SSR over SSG?”
  • “How does data fetching change between the Pages Router and the App Router?”

Answers by Technology

+ Add Variant
Next.jsImprove this answer ✏️

Expected Answer

Next.js offers several ways to render content, each suited for different use cases:

  1. Static Site Generation (SSG): HTML is generated at build time. This is the most performant method. In the Pages Router, this uses getStaticProps. In the App Router (Next.js 13+), this is the default behavior for fetch requests unless opted out.
  2. Server-Side Rendering (SSR): HTML is generated on each request. In the Pages Router, this uses getServerSideProps. In the App Router, you opt-in by setting cache: 'no-store' in fetch or using dynamic functions.
  3. Incremental Static Regeneration (ISR): Allows you to update static pages after build time. Introduced in Next.js 9.5, it scales well for large sites.
  4. Client-Side Rendering (CSR): Only the initial shell is sent from the server, and the browser fetches data and renders the rest. Used for highly interactive dashboards or parts of a page that don’t need SEO.

Why It Matters

Choosing the wrong strategy can lead to slow TTI (Time to Interactive), poor SEO, or high server costs. SSG is preferred for performance, but ISR is often the “sweet spot” for modern apps, combining static speed with dynamic updates.

Example Code

SSG / ISR (App Router)

TypeScript

// app/blog/[slug]/page.tsx
async function getPageData(slug: string) {
  const res = await fetch(`https://api.example.com/posts/${slug}`, {
    next: { revalidate: 60 } // ISR: Revalidate every 60 seconds
  });
  return res.json();
}

JavaScript

// app/blog/[slug]/page.js
async function getPageData(slug) {
  const res = await fetch(`https://api.example.com/posts/${slug}`, {
    next: { revalidate: 60 }
  });
  return res.json();
}

SSR (App Router)

TypeScript

// Force dynamic rendering (no cache)
async function getDynamicData() {
  const res = await fetch('https://api.example.com/stats', {
    cache: 'no-store'
  });
  return res.json();
}

JavaScript

// Force dynamic rendering (no cache)
async function getDynamicData() {
  const res = await fetch('https://api.example.com/stats', {
    cache: 'no-store'
  });
  return res.json();
}

Common Mistakes

  • Using SSR for everything: This increases server load and TTFB (Time to First Byte) unnecessarily.
  • Forgetting about revalidate in ISR: Leaving it at build-only for content that actually changes.
  • Fetching secret data on the client: Exposing API keys or sensitive information in the browser.

Follow-up Questions

  • What happens during the revalidation period in ISR? (Answer: The first visitor after the period triggers a background regeneration. They get the stale page, and subsequent visitors get the new page).
  • How do you handle private data with SSG? (Answer: You usually can’t pre-render private data. You either use SSR or fetch that specific piece of data on the client).

References