Interview kitsBlog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2026 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Next.js
Next.jsmedium

SSR vs SSG vs ISR — what’s the difference in Next.js?

Tags
#ssr#ssg#isr#caching
Back to categoryPractice quiz

Answer

SSR renders on every request, SSG renders at build time, and ISR regenerates pages in the background after a revalidate interval. It’s a trade-off between freshness, speed, and build time.

Advanced answer

Deep dive

These terms describe *when* HTML is generated and how freshness is handled.

  • **SSR (Server-Side Rendering)**: render on each request. Best for highly dynamic or personalized pages, but can be slower and more expensive at scale.
  • **SSG (Static Site Generation)**: render at build time. Extremely fast at runtime (CDN), but content is as fresh as your last build.
  • **ISR (Incremental Static Regeneration)**: serve a cached/static version and regenerate in the background after a revalidate interval.

App Router mapping

In the App Router, this is mostly controlled by caching/revalidation:

  • static + cached data → SSG-like,
  • `revalidate` → ISR-like,
  • `no-store` / dynamic route segment → SSR-like.

Example

// Revalidate this route every 60s (ISR-like)
export const revalidate = 60

// Per-request (SSR-like)
await fetch(url, { cache: 'no-store' })

Practical guidance

  • Use SSG/ISR for content that can be slightly stale (marketing/docs/content pages).
  • Use SSR for auth-dependent dashboards and per-user pages.

Common pitfalls

  • Accidentally forcing SSR by reading `cookies()`/`headers()` where you expected static output.
  • Overusing SSR and losing CDN caching benefits.
  • Setting long revalidate windows for data that must be fresh.

Related questions

Next.js
Dynamic routes: what does `generateStaticParams` do?
#nextjs#ssg#dynamic-routes
Next.js
Static vs dynamic rendering — how do you force a route to be dynamic and why?
#ssr#dynamic#cache
Next.js
What causes a hydration mismatch in React/Next.js and how do you fix it?
#hydration#ssr#react
Next.js
Explain caching and revalidation in Next.js (fetch cache, revalidatePath).
#caching#revalidation#fetch
Next.js
What is Incremental Static Regeneration (ISR) and when to use it?
#isr#ssg#caching
Next.js
SSR vs SSG?
#nextjs#rendering#ssr