<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Frontend Blogging]]></title><description><![CDATA[Frontend Blogging]]></description><link>https://frontend-blogging.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 23:16:33 GMT</lastBuildDate><atom:link href="https://frontend-blogging.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[CSR vs SSR vs SSG in React: A Quick Overview ⚡]]></title><description><![CDATA[When you build a React app, one decision quietly shapes its speed, SEO and hosting: where and when the HTML gets rendered. The three main options are…]]></description><link>https://frontend-blogging.hashnode.dev/csr-vs-ssr-vs-ssg-in-react-a-quick-overview</link><guid isPermaLink="true">https://frontend-blogging.hashnode.dev/csr-vs-ssr-vs-ssg-in-react-a-quick-overview</guid><category><![CDATA[React]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[vite]]></category><dc:creator><![CDATA[Sahil Maddi]]></dc:creator><pubDate>Tue, 10 Nov 2026 02:42:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/653b961d0f79ef82f41fd905/22348665-f24e-453d-a343-d4af4c52e818.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you build a React app, one decision quietly shapes its speed, SEO and hosting: <strong>where and when the HTML gets rendered</strong>. The three main options are <strong>Client-Side Rendering (CSR)</strong>, <strong>Server-Side Rendering (SSR)</strong> and <strong>Static Site Generation (SSG)</strong>. This quick overview explains each one, its trade-offs, and when to choose it.</p>
<h2>Client-Side Rendering (CSR) 🖥️</h2>
<p>With CSR, the server sends an almost empty HTML file (usually just <code>&lt;div id="root"&gt;&lt;/div&gt;</code>) plus a JavaScript bundle. The browser downloads the JavaScript, runs React, and only then builds the page.</p>
<p><strong>How it works:</strong></p>
<ol>
<li>The browser requests the page and gets a nearly empty HTML file.</li>
<li>It downloads and runs the JavaScript bundle.</li>
<li>React renders the UI in the browser.</li>
</ol>
<p><strong>Pros:</strong></p>
<ul>
<li><strong>Simple setup:</strong> a plain Vite + React app is CSR by default.</li>
<li><strong>Cheap hosting:</strong> the output is static files, so any CDN can serve it.</li>
<li><strong>Smooth navigation:</strong> after the first load, moving between pages feels instant.</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><strong>Slower first paint:</strong> users see a blank screen until the JavaScript loads and runs, which hurts on slow phones and networks.</li>
<li><strong>Weaker SEO and link previews:</strong> crawlers and social media previews may see an empty page.</li>
</ul>
<p><strong>Best for:</strong> dashboards, admin panels and apps behind a login, where SEO doesn't matter.</p>
<h2>Server-Side Rendering (SSR) 🌐</h2>
<p>With SSR, the server runs React for <strong>every request</strong>, sends fully rendered HTML, and then the browser <strong>hydrates</strong> it, meaning React attaches event handlers to the HTML that's already there.</p>
<p><strong>How it works:</strong></p>
<ol>
<li>The browser requests a page.</li>
<li>The server fetches data, renders React to HTML and sends it.</li>
<li>The browser shows the HTML immediately, then hydrates it to make it interactive.</li>
</ol>
<p><strong>Pros:</strong></p>
<ul>
<li><strong>Fast first paint:</strong> content is visible before the JavaScript finishes loading.</li>
<li><strong>Great SEO:</strong> crawlers get complete HTML.</li>
<li><strong>Always fresh data:</strong> each request renders with the latest data.</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><strong>Needs a server:</strong> every request costs server time, so hosting is more complex and expensive than static files.</li>
<li><strong>Slower time to first byte:</strong> the server must finish rendering before it responds.</li>
<li><strong>Hydration bugs:</strong> if the server and browser render different output (for example, using <code>Date.now()</code> or <code>window</code> during render), React warns about a mismatch.</li>
</ul>
<p><strong>Best for:</strong> pages with frequently changing or personalised data that must be indexable, like e-commerce product pages or news feeds. Frameworks like <strong>Next.js</strong> make SSR straightforward.</p>
<h2>Static Site Generation (SSG) ⚡</h2>
<p>With SSG, pages are rendered to HTML <strong>once, at build time</strong>. The result is plain HTML files that a CDN serves instantly, which React then hydrates in the browser.</p>
<p><strong>How it works:</strong></p>
<ol>
<li>During the build, React renders each page to HTML.</li>
<li>The HTML files are deployed to a CDN.</li>
<li>Visitors get pre-rendered HTML straight away, and React hydrates it.</li>
</ol>
<p><strong>Pros:</strong></p>
<ul>
<li><strong>Fastest delivery:</strong> no rendering at request time, just files from a CDN.</li>
<li><strong>Great SEO:</strong> complete HTML for every page.</li>
<li><strong>Cheap and reliable hosting:</strong> no server to scale or keep running.</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><strong>Data can go stale:</strong> content updates need a rebuild (or a hybrid approach like incremental regeneration in Next.js).</li>
<li><strong>Long builds for huge sites:</strong> thousands of pages mean thousands of renders at build time.</li>
</ul>
<p><strong>Best for:</strong> portfolios, blogs, documentation and marketing pages, where content changes rarely.</p>
<h2>Side-by-side comparison</h2>
<table>
<thead>
<tr>
<th></th>
<th>CSR</th>
<th>SSR</th>
<th>SSG</th>
</tr>
</thead>
<tbody><tr>
<td>Where HTML is rendered</td>
<td>Browser</td>
<td>Server, per request</td>
<td>Build step, once</td>
</tr>
<tr>
<td>First paint</td>
<td>Slowest</td>
<td>Fast</td>
<td>Fastest</td>
</tr>
<tr>
<td>SEO</td>
<td>Weak</td>
<td>Strong</td>
<td>Strong</td>
</tr>
<tr>
<td>Data freshness</td>
<td>Live (fetched in browser)</td>
<td>Live (per request)</td>
<td>As of last build</td>
</tr>
<tr>
<td>Hosting</td>
<td>Static files</td>
<td>Node.js server</td>
<td>Static files</td>
</tr>
<tr>
<td>Typical tools</td>
<td>Vite + React</td>
<td>Next.js, React Router (framework mode)</td>
<td>Next.js, Astro, Vite with pre-rendering</td>
</tr>
</tbody></table>
<h2>How to choose</h2>
<ul>
<li><strong>Is the page behind a login?</strong> CSR is usually fine.</li>
<li><strong>Does it need SEO and change on every request?</strong> Use SSR.</li>
<li><strong>Does it need SEO but change rarely?</strong> Use SSG.</li>
<li><strong>Mixed needs?</strong> Frameworks like Next.js let you choose per page, so a blog can be static while the account page renders on the client.</li>
</ul>
<h2>A practical tip: pre-render a Vite app</h2>
<p>You don't need a full framework to get SSG-like speed. A Vite + React app can render its pages to HTML at build time using <code>renderToString</code> from <code>react-dom/server</code>, insert that HTML into <code>index.html</code>, and switch the client entry from <code>createRoot</code> to <code>hydrateRoot</code>. Visitors then see content immediately, which improves Lighthouse metrics like <strong>First Contentful Paint</strong> and <strong>Largest Contentful Paint</strong>, while you keep the simplicity of static hosting.</p>
<h2>Conclusion</h2>
<p>There's no single best rendering strategy, only the best fit for each page. <strong>CSR</strong> keeps things simple for app-like pages, <strong>SSR</strong> delivers fresh, indexable content on every request, and <strong>SSG</strong> gives the fastest pages for content that rarely changes. Pick based on how often your data changes and whether search engines need to see it. 🚀</p>
]]></content:encoded></item></channel></rss>