DEV Community

Cover image for Rendering Methods in React: CSR vs SSR vs SSG vs ISR
MD Mohsanul Hoda
MD Mohsanul Hoda

Posted on

Rendering Methods in React: CSR vs SSR vs SSG vs ISR

What is Rendering?

Rendering is the process of converting your React components (written in JSX) into real HTML and JavaScript that the browser can understand and display.
Browsers don’t understand React or JSX directly — they only understand plain HTML, CSS, and JavaScript. So before anything appears on the screen, React must transform (or "render") those components into code the browser can use.

🔄 Why Rendering Matters

Rendering determines:

  • When and where the HTML is created (on the client or the server)
  • How fast the content shows up to users
  • How well search engines (SEO) can read the page
  • User experience (e.g., loading spinners vs pre-filled content)

React (especially with frameworks like Next.js) provides multiple ways to render your application based on your needs:

  • CSR (Client-Side Rendering)
  • SSR (Server-Side Rendering)
  • SSG (Static Site Generation)
  • ISR (Incremental Static Regeneration)

Client-Side Rendering

Client-Side Rendering means the browser is responsible for building and displaying the web page. When someone visits your React app, the server sends back a nearly empty HTML file and a JavaScript bundle. The actual page content is built inside the browser, using JavaScript, not on the server.
In React apps, JavaScript uses something called the Virtual DOM to generate the user interface. Until this process finishes, users may briefly see a blank screen.

⚙️ What Happens Behind the Scenes?
Here's what goes on, step by step:

🌐 User visits a URL
📄 Server sends back a basic HTML shell
📦 Browser downloads the JavaScript bundle
🧠 React runs in the browser and builds the UI from the Virtual DOM
🔌 App fetches data from APIs if needed
🖱️ Page becomes interactive — users can now click, scroll, and navigate

🧠 When Should You Use CSR?
Use CSR when:

  • You’re building a highly interactive app (e.g., dashboards, single-page apps)
  • SEO isn’t a top priority
  • You want a lighter server load

👍 Benefits

✔ Lighter load on the server — the server just sends static files.
✔ Cheaper server costs — less computing needed per request.
✔ Smooth client-side experiences — ideal for highly interactive apps.

👎 Drawbacks

❌ Slower initial page load — users may wait for the JS to build the UI
❌ Not SEO-friendly — search engines may not see your content

Server-Side Rendering (SSR)

Server-Side Rendering means the server generates the complete HTML for the page on each request and sends it to the browser. This means users see a fully rendered page almost instantly — no blank screen while JavaScript loads.

In React apps (like those built with Next.js), React runs on the server, builds the page based on your components and data, and sends back the finished HTML. Once the page is loaded in the browser, React “hydrates” it — attaching event listeners and making it interactive.

⚙️ What Happens Behind the Scenes?

🌐 User visits a URL
💡 Server runs React code to generate the HTML content
📄 Server sends back a fully rendered HTML page
⚙️ Browser shows the content immediately
📦 Browser then downloads the JavaScript bundle
🔁 React hydrates the page to make it interactive (adds event handlers, etc.)
🔌 Any extra data fetching or updates happen as needed

🧠 When Should You Use SSR?

  • You want a fast initial page load
  • SEO is important — search engines can read the page content
  • You need fresh data every time the page is loaded (e.g., SEO-critical content, blogs, news)

👍 Benefits

✔ Faster first paint — users see content immediately
✔ Better SEO — search engines can index fully rendered content
✔ Useful for dynamic pages with content that changes frequently

👎 Drawbacks

❌ Heavier server load — the server must render HTML for every request
❌ Slightly longer time to become interactive (hydration happens after HTML is shown)
❌ More complex setup compared to CSR

Static Site Generation (SSG)

Static Site Generation means that your pages are built into HTML at build time, not on each request. When you deploy your site, the server generates all the necessary HTML in advance and stores it as static files. Then, whenever a user visits the site, they get the pre-built page instantly — no need to wait for the server to generate anything.

In React apps, this is commonly used with Next.js, where the HTML for each page is generated during the build process, and JavaScript adds interactivity once the page loads.

⚙️ What Happens Behind the Scenes?

🏗️ During build time, the server runs your React code
🧱 It creates HTML files for each page and stores them as static asset
🌐 User visits a URL
📄 Server sends the already-built HTML immediately
📦 Browser downloads JavaScript to make the page interactive (hydration)
🔁 Any API data fetched after load (if needed)

🧠 When Should You Use SSG?

  • Your content doesn’t change often (e.g., Marketing pages, documentation, documentation, landing pages)
  • You want fast performance and great SEO
  • You want to serve pages from a CDN for global speed

👍 Benefits

✔ Super fast load times — no need to generate pages on the fly
✔ Very SEO-friendly — pages are already fully rendered
✔ Scales easily — static files can be served from a CDN
✔ Cheaper hosting — no need for a powerful server

👎 Drawbacks

❌ Not suitable for pages that need real-time data
❌ Rebuild required to update content (unless you use ISR)
❌ Can lead to longer build times if you have many pages

Incremental Static Regeneration (ISR)

Incremental Static Regeneration (ISR) is a hybrid approach that combines the speed of Static Site Generation (SSG) with the flexibility of Server-Side Rendering (SSR).

With ISR, pages are pre-rendered at build time, just like SSG. But here’s the twist: you can update specific pages in the background — without rebuilding the entire site. This allows you to keep your static site fast and up-to-date with dynamic content.

ISR is available in frameworks like Next.js, where you can define how often a page should be re-generated (e.g., every 10 seconds).

⚙️ What Happens Behind the Scenes?

🏗️ During build time, the server generates static HTML files
🌐 User visits a page — they get the static HTML instantly
⏱️ If the page is older than a set time (revalidate), it’s rebuilt in the background
🚀 On the next request, the user sees the updated page
🔁 Meanwhile, the browser loads JavaScript and makes the page interactive (hydration)

🧠 When Should You Use ISR?

  • Your content changes occasionally and doesn’t need to update on every request
  • You want the speed of static pages with the flexibility of fresh data
  • You're building news, e-commerce, or listings that update regularly

👍 Benefits

✔ Fast performance like SSG
✔ Content stays up to date without full rebuilds
✔ Great for SEO — pages are pre-rendered
✔ Scalable and efficient — works well for large sites with lots of pages

👎 Drawbacks

❌ Slight complexity — may require more config and logic
❌ Content isn’t updated instantly — there’s a short delay based on the revalidation interval
❌ Debugging issues related to caching or stale content can be tricky

Top comments (0)