Next.js has revolutionized web development with its App Router architecture. At the heart of this revolution is the ability to control how your UI is "rendered"—more flexibly and powerfully than ever before. Understanding these rendering strategies not only helps you build faster, more SEO-optimized apps, but also delivers a superior user experience.
Let’s explore and master the four main rendering strategies in Next.js!
🍽️ The Rendering Feast: Meet the 4 "Chefs"
Think of rendering a web page like preparing a dish in a restaurant. Next.js gives you four types of "chefs," each suited to a different "guest" (use case).
1. Static Site Generation (SSG) – "Prepared in Advance" 🥪
This is the default strategy of the App Router.
- What is it? Static Site Generation (SSG) renders your pages into static HTML files at build time (when you run
npm run build
). - How does it work? Next.js fetches data and renders your page once at build time. The result is lean HTML, CSS, and JS files. When a user visits, the server simply serves these pre-built files—no extra computation needed.
- When to use?
- Pages with rarely changing content: blog posts, about pages, documentation, policy pages.
- Landing pages, marketing pages.
- Any page where content can be determined ahead of time and is the same for all users.
- Pros:
- ⚡ Blazing fast: Response time is nearly instant since there’s no server processing.
- 🔒 Safe & Reliable: Minimal attack surface—no database or server-side logic at runtime.
- 🔎 SEO-friendly: Search engines can easily read and index the full HTML content.
- Cons:
- Content isn’t updated until the next build.
2. Server-Side Rendering (SSR) – "Made to Order" 🍜
The strategy for always-fresh content.
- What is it? Server-Side Rendering (SSR) renders a page on the server at request time (every time a user visits).
- How does it work? On each request, the Next.js server fetches the latest data, renders the page to HTML, and sends it to the browser. Every visit triggers a new render. In the App Router, you enable this by using dynamic functions like
headers()
,cookies()
, orsearchParams
, or by declaringexport const dynamic = 'force-dynamic'
. - When to use?
- Pages that need to show always-updated, user-specific data: dashboards, shopping carts, social feeds.
- Pages where content depends on user info (like cookies).
- Pros:
- 🔄 Always fresh data: Users always see the latest info.
- 🔑 Highly personalized: Content can be tailored for each user.
- Cons:
- Slower than SSG since the server works on every request.
- Higher server costs due to more processing.
3. Incremental Static Regeneration (ISR) – "Periodically Reheated" 🍲
The perfect blend of SSG speed and SSR freshness.
-
What is it? Incremental Static Regeneration (ISR) lets you update static pages after build—without rebuilding the whole site.
-
How does it work? The page is statically rendered at build. You set a revalidate interval. When a request comes in after this interval, Next.js serves the old static page, but quietly regenerates it in the background with fresh data. Future visits get the updated page.
// app/products/[id]/page.js export const revalidate = 3600 // Revalidate this page every hour (3600 seconds) async function getProduct(id) { const res = await fetch(`https://api.example.com/products/${id}`) return res.json() }
-
When to use?
- Product pages in e-commerce (prices and stock may change).
- News or event pages (content updated periodically).
- Any page where you want SSG speed but still need reasonably fresh content.
-
Pros:
- Great balance between performance and data freshness.
- Less load on server and database compared to SSR.
-
Cons:
- The first user after the revalidate interval may see slightly outdated data for a moment.
4. Client-Side Rendering (CSR) – "Self-Serve Kit" 🥗
CSR still plays a key role in the App Router ecosystem.
- What is it? Client-Side Rendering (CSR) renders the UI directly in the user’s browser using JavaScript.
- How does it work? The server sends a nearly empty HTML page and JS files. The browser then runs the JS to fetch data and "draw" the full UI. To use CSR, mark your component with the
"use client"
directive. - When to use?
- Highly interactive UI parts: complex forms, real-time product filters, text editors.
- Dashboard components that need frequent updates without page reloads.
- Pros:
- Rich interactivity, desktop-app-like experience.
- Reduces server load after the initial load.
- Cons:
- Initial load can be slower (First Contentful Paint).
- SEO can suffer if not configured properly, as search bots may not see full content immediately.
💪 The Hybrid Power: Mix and Match
The real beauty of the Next.js App Router is not picking just one strategy, but combining them all in a single app—even on the same page!
You can have:
- A main layout statically rendered (SSG).
- Inside that layout, a product list regenerated periodically (ISR).
- A user info bar dynamically rendered (SSR) based on cookies.
- And a highly interactive product filter client-rendered (CSR).
This mix lets you optimize every part of your app for the best performance, SEO, and user experience.
Conclusion: Master Rendering Strategies
Mastering rendering strategies in the Next.js App Router is the key to unlocking the full potential of this framework.
Strategy | When is it rendered? | Data | Speed | SEO | Use Case |
---|---|---|---|---|---|
SSG | Build time | Stale | ⚡ Fastest | ✅ Best | Blog, about pages |
SSR | Request time | 🔄 Freshest | Slower | ✅ Good | Dashboard, cart |
ISR | Build + periodic | Nearly fresh | 🚀 Very fast | ✅ Good | Product, news pages |
CSR | Runtime (browser) | 🔄 Freshest | Depends | ⚠️ Needs config | Forms, interactive parts |
Instead of being limited to a single approach, you now have a powerful toolkit to choose the best solution for each problem. Start by identifying the nature of your data and interaction needs for each page, then pick the rendering "chef" that fits best.
Good luck building faster, stronger Next.js apps than ever before!