Rendering Explained: CSR, SSR, SSG and ISR

Next.js Course: Beginner to Advanced with Examples · Next.js Introduction · 5 min read · Updated

Four ways to make a page

  1. SSG builds the page once at build time and stores it.
  2. SSR builds the page on the server for each visit, so it is always fresh.
  3. ISR sends the stored page and quietly makes a new copy after the set time.
  4. CSR sends code and lets the browser build the page.

Rendering means turning your React code into the HTML that a person sees. The big question is where and when that happens. Think of a bakery. One bakery bakes the bread only when you order it. Another bakes everything at dawn and just hands it over. A third sends you flour and a recipe and lets you bake at home. All three give you bread, but the speed, the cost and the freshness are different. Rendering in Next.js works the same way.

Client-side rendering (CSR)

With client-side rendering the server sends an almost empty page and some JavaScript. The browser runs that JavaScript and builds the page on the user’s device. This is how a plain React app made with older tools works. It is like being sent flour and a recipe.

  • Good: after the first load, moving around the app feels quick, and the server does very little work.
  • Not so good: the user sees a blank screen or a spinner until the JavaScript has loaded and run. Search engines and link previews may see little content.

CSR is still very useful for parts of a page that depend on the user, such as a live chart or a form with lots of clicking. Next.js lets you use it for those parts only.

Server-side rendering (SSR)

With server-side rendering, the server builds the full HTML for every request and sends it. The browser shows the content straight away, and then React makes it interactive. This is the bakery that bakes the bread after you order it.

  • Good: the page is always fresh and personal, because it is made at request time. The HTML is complete, which is good for search engines.
  • Not so good: every visit costs the server some work and the user waits for that work. A slow database makes a slow page.

Use SSR when the content changes all the time or depends on who is asking, for example a page that shows the current user’s orders.

Static site generation (SSG)

With static generation, the HTML is built once, at build time, before anyone visits. The finished file can be stored on a fast network of servers around the world and sent in a moment. This is the bakery that bakes everything at dawn.

  • Good: very fast and cheap, and it handles a huge number of visitors easily.
  • Not so good: the page shows what was true at build time. If your content changes, you must build again, unless you use the next idea.

SSG is perfect for pages that rarely change: a home page, an about page, a blog post or a documentation page.

Incremental static regeneration (ISR)

ISR keeps the speed of static pages but lets them refresh. You tell Next.js how old a page may get. After that time, the next visit still gets the old page quickly, and in the background Next.js builds a new copy for the visits after it. The bakery bakes at dawn but quietly swaps in a fresh loaf every hour.

ISR is a good fit for a product page that changes a few times a day or a blog with many posts, where rebuilding the whole site for one edit would be slow. You will see how to control the refresh time in the data fetching module.

A table to remember

  • CSR: built in the browser. Best for interactive parts.
  • SSR: built on the server for each request. Best for fresh or personal pages.
  • SSG: built once at build time. Best for pages that rarely change.
  • ISR: built at build time and refreshed later. Best for pages that change slowly.

How Next.js 16 describes this today

In the App Router you do not usually pick one of these four names for a whole page. Instead Next.js decides how to prepare each page and each part of a page. A part that does not depend on the request can be built ahead of time. A part that needs fresh data or the user’s cookies is built when the visit happens, and Next.js can stream it into the page. Newer versions call the mix of the two Partial Prerendering. In the route list printed by next build you can see this. A circle means the page was prepared as static content, and a half circle means a static shell with dynamic parts that stream in.

Route (app)
┌ ○ /
├ ○ /_not-found
├ ○ /about
├ ○ /blog
├   /blog/[slug]
│ ├ ◐ /blog/[slug]
│ ├ ○ /blog/hello-nextjs
│ └ ○ /blog/routing-basics
├   /docs/[[...slug]]
│ └ ◐ /docs/[[...slug]]
├ ○ /old-page
├ ○ /pricing
└   /shop/[...slug]
  └ ◐ /shop/[...slug]

○  (Static)             prerendered as static content
◐  (Partial Prerender)  prerendered as static HTML with dynamic server-streamed content

The list above comes from the example app that we build in the next lessons. The routes with a half circle have a part that needs the request, such as the address of the page, so that part is sent when the visit happens. Do not worry if this feels new. You will practise it step by step.

Your task

  1. For each page, write which rendering style fits best and why: a home page, an about page, a news page that changes every minute, a page that shows the logged-in user’s name, and a blog post.
  2. Explain ISR to a friend using the bakery or any example of your own.
  3. Open the home page of any large site. Right-click, choose View page source, and see whether the content is in the HTML or only a few script tags.

How to check it worked

  • You can say where and when each style builds the page.
  • You can give one good use for CSR, SSR, SSG and ISR.
  • You can explain the circle and half circle in the build output.

Frequently asked questions

Which rendering style is the best?

None is best for everything. Use static pages for content that rarely changes, server rendering for fresh or personal content, and client rendering for interactive parts. Next.js lets you mix them in one app.

Does Next.js use SSR or SSG by default?

In the App Router, Next.js prepares what it can ahead of time and builds the rest when the request arrives. The route list from next build shows what happened to each page.

Is client-side rendering bad for SEO?

It can be, because the first HTML has little content. That is why Next.js sends ready HTML by default and uses client rendering only where it is needed.