{"componentChunkName":"component---src-templates-blog-post-blog-post-js","path":"/rendering-methods/","result":{"data":{"site":{"siteMetadata":{"title":"girgetto.it"}},"markdownRemark":{"id":"64505be7-79ae-5dd9-ab3f-8c4e5501236e","excerpt":"Modern frontend frameworks give developers several strategies for delivering content to the browser. Choosing the right one dramatically affects performance…","html":"<p>Modern frontend frameworks give developers several strategies for delivering content to the browser. Choosing the right one dramatically affects performance, SEO, and user experience. This post covers the four most important rendering methods — <strong>CSR</strong>, <strong>SSR</strong>, <strong>SSG</strong>, and <strong>Hydration</strong> — with a diagram for each.</p>\n<hr>\n<h2 id=\"client-side-rendering-csr\" style=\"position:relative;\"><a href=\"#client-side-rendering-csr\" aria-label=\"client side rendering csr permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Client-Side Rendering (CSR)</h2>\n<p>In CSR the browser downloads a minimal HTML shell and a JavaScript bundle. The JS then runs in the browser, fetches data, and constructs the full page on the client.</p>\n<p><strong>Frameworks:</strong> React (CRA / Vite SPA), Vue (Vite SPA), Angular</p>\n<div class=\"mermaid\">\nsequenceDiagram\n    participant B as 🌐 Browser\n    participant S as 🖥️ Server\n\n    B->>S: GET /index.html\n    S-->>B: Empty HTML ⟨div id=\"root\"⟩⟨/div⟩\n    B->>S: GET /bundle.js\n    S-->>B: bundle.js (~500 KB)\n    Note over B: JS executes — builds the DOM\n    B->>S: fetch('/api/data')\n    S-->>B: JSON data\n    Note over B: UI fully rendered ✅\n</div>\n<h3 id=\"how-csr-works-step-by-step\" style=\"position:relative;\"><a href=\"#how-csr-works-step-by-step\" aria-label=\"how csr works step by step permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How CSR works step by step</h3>\n<ol>\n<li>Browser requests the page → server returns a nearly empty HTML file</li>\n<li>Browser downloads the JavaScript bundle</li>\n<li>JS runs in the browser and builds the DOM</li>\n<li>Data is fetched from APIs and the UI is rendered</li>\n</ol>\n<blockquote>\n<p><strong>⚠️ The page is completely blank until the JS bundle has downloaded and executed.</strong> This hurts both perceived performance and SEO crawlers that don't run JS.</p>\n</blockquote>\n<h3 id=\"pros-and-cons\" style=\"position:relative;\"><a href=\"#pros-and-cons\" aria-label=\"pros and cons permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pros and Cons</h3>\n<table>\n<thead>\n<tr>\n<th>✅ Pros</th>\n<th>❌ Cons</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Rich, app-like interactions</td>\n<td>Slow initial load (blank screen)</td>\n</tr>\n<tr>\n<td>Low server load</td>\n<td>Poor SEO out of the box</td>\n</tr>\n<tr>\n<td>Simple deployment (static host)</td>\n<td>Large JS bundles</td>\n</tr>\n<tr>\n<td>Fast navigation after first load</td>\n<td>Requires JS enabled</td>\n</tr>\n</tbody>\n</table>\n<blockquote>\n<p><strong>Best for:</strong> Dashboards, admin panels, apps behind a login, real-time tools.</p>\n</blockquote>\n<hr>\n<h2 id=\"server-side-rendering-ssr\" style=\"position:relative;\"><a href=\"#server-side-rendering-ssr\" aria-label=\"server side rendering ssr permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Server-Side Rendering (SSR)</h2>\n<p>With SSR the server generates the full HTML for each request. The browser receives a complete, readable page immediately. JavaScript then runs to make the page interactive.</p>\n<p><strong>Frameworks:</strong> Next.js (<code>getServerSideProps</code>), Nuxt.js, SvelteKit, Remix</p>\n<div class=\"mermaid\">\nsequenceDiagram\n    participant B as 🌐 Browser\n    participant S as 🖥️ Server\n    participant D as 🗄️ Database / API\n\n    B->>S: GET /page\n    S->>D: Query data\n    D-->>S: Data response\n    Note over S: Renders full HTML on server\n    S-->>B: Full HTML page ✅\n    Note over B: Content visible immediately (fast FCP)\n    B->>S: GET /bundle.js\n    S-->>B: JS bundle\n    Note over B: Hydration — page becomes interactive ✅\n</div>\n<h3 id=\"how-ssr-works-step-by-step\" style=\"position:relative;\"><a href=\"#how-ssr-works-step-by-step\" aria-label=\"how ssr works step by step permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How SSR works step by step</h3>\n<ol>\n<li>Browser sends a request for a page</li>\n<li>Server fetches data from the database or API</li>\n<li>Server renders the full HTML and sends it to the browser</li>\n<li>Browser displays the HTML immediately (fast First Contentful Paint)</li>\n<li>Browser downloads JS and <strong>hydrates</strong> the page to add interactivity</li>\n</ol>\n<blockquote>\n<p><strong>⚠️ This entire cycle runs on every request.</strong> The server must be available, fast, and horizontally scalable.</p>\n</blockquote>\n<h3 id=\"pros-and-cons-1\" style=\"position:relative;\"><a href=\"#pros-and-cons-1\" aria-label=\"pros and cons 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pros and Cons</h3>\n<table>\n<thead>\n<tr>\n<th>✅ Pros</th>\n<th>❌ Cons</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Excellent SEO</td>\n<td>Higher server load per request</td>\n</tr>\n<tr>\n<td>Fast initial paint (content visible)</td>\n<td>More complex infrastructure</td>\n</tr>\n<tr>\n<td>Dynamic, always-fresh data</td>\n<td>Cold start delays (serverless)</td>\n</tr>\n<tr>\n<td>Works without JS</td>\n<td>Slower than static file serving</td>\n</tr>\n</tbody>\n</table>\n<blockquote>\n<p><strong>Best for:</strong> E-commerce product pages, news articles, pages that need fresh data on every request.</p>\n</blockquote>\n<hr>\n<h2 id=\"static-site-generation-ssg\" style=\"position:relative;\"><a href=\"#static-site-generation-ssg\" aria-label=\"static site generation ssg permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Static Site Generation (SSG)</h2>\n<p>SSG pre-renders all pages at <strong>build time</strong>. The result is a set of plain HTML files deployed to a CDN. No server is needed at request time.</p>\n<p><strong>Frameworks:</strong> Next.js (<code>getStaticProps</code>), Gatsby, Astro, Hugo, Eleventy</p>\n<div class=\"mermaid\">\nflowchart TD\n    subgraph Build[\"🔨 Build Time — runs once\"]\n        C[\"📁 Content\\nMD / JSON / CMS\"] --> BT[\"⚙️ Build Tool\\nNext.js / Gatsby\"]\n        BT --> H[\"📄 Static HTML Files\"]\n        H --> D[\"🚀 Deploy to CDN\\nVercel / Netlify / S3\"]\n    end\n\n    subgraph Runtime[\"🌍 Request Time — instant\"]\n        Browser[\"🌐 Browser\"] -->|\"GET /page\"| Edge[\"☁️ CDN Edge Node\\ncached globally\"]\n        Edge -->|\"Pre-built HTML ⚡\"| Browser\n    end\n\n    D --> Edge\n</div>\n<h3 id=\"how-ssg-works-step-by-step\" style=\"position:relative;\"><a href=\"#how-ssg-works-step-by-step\" aria-label=\"how ssg works step by step permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How SSG works step by step</h3>\n<ol>\n<li>At <strong>build time</strong>, the framework fetches all data and renders every page to HTML</li>\n<li>The HTML files are uploaded to a CDN</li>\n<li>At <strong>request time</strong>, the browser gets the pre-built HTML from the nearest CDN edge node — no server execution needed</li>\n</ol>\n<blockquote>\n<p><strong>⚠️ Data can become stale between builds.</strong> A new deploy is required for content changes unless ISR (Incremental Static Regeneration) is used.</p>\n</blockquote>\n<h3 id=\"pros-and-cons-2\" style=\"position:relative;\"><a href=\"#pros-and-cons-2\" aria-label=\"pros and cons 2 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pros and Cons</h3>\n<table>\n<thead>\n<tr>\n<th>✅ Pros</th>\n<th>❌ Cons</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Blazing fast (files from CDN edge)</td>\n<td>Data can become stale</td>\n</tr>\n<tr>\n<td>Excellent SEO</td>\n<td>Rebuild required for content changes</td>\n</tr>\n<tr>\n<td>Highly scalable (no server)</td>\n<td>Long build times for large sites</td>\n</tr>\n<tr>\n<td>Very secure</td>\n<td>Not suitable for user-specific pages</td>\n</tr>\n</tbody>\n</table>\n<blockquote>\n<p><strong>Best for:</strong> Blogs, documentation sites, marketing pages, portfolios.</p>\n</blockquote>\n<hr>\n<h2 id=\"hydration\" style=\"position:relative;\"><a href=\"#hydration\" aria-label=\"hydration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Hydration</h2>\n<p>Hydration is the process that makes a server-rendered or statically generated HTML page <strong>interactive</strong>. The browser receives full HTML (fast paint), then JS is loaded and \"wired up\" to the existing DOM — attaching event listeners and state without re-rendering.</p>\n<div class=\"mermaid\">\nflowchart TD\n    A[\"① Server HTML\\n📄 Full HTML sent\\nVisible ✅\\nNot Interactive ❌\"]\n    B[\"② JS Bundle Loads\\n⬇️ Downloading...\\nVisible ✅\\nNot Interactive ❌\"]\n    C[\"③ Hydrating\\n💧 Attaching events\\nVisible ✅\\nPartial ⚠️\"]\n    D[\"④ Interactive\\n✅ Framework controls DOM\\nVisible ✅\\nInteractive ✅\"]\n\n    A -->|Browser receives| B\n    B -->|JS executes| C\n    C -->|Complete| D\n\n    style A fill:#f1f5f9,stroke:#94a3b8,color:#334155\n    style B fill:#dbeafe,stroke:#3b82f6,color:#1e40af\n    style C fill:#fef9c3,stroke:#eab308,color:#713f12\n    style D fill:#dcfce7,stroke:#22c55e,color:#166534\n</div>\n<h3 id=\"the-hydration-problem\" style=\"position:relative;\"><a href=\"#the-hydration-problem\" aria-label=\"the hydration problem permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The Hydration problem</h3>\n<p>Hydration introduces <strong>Time To Interactive (TTI)</strong>: the page <em>looks</em> ready but is <strong>not clickable</strong> until JS finishes hydrating. On slow networks or heavy JS bundles, this gap frustrates users.</p>\n<deckgo-highlight-code   >\n          <code slot=\"code\">FCP ─────────────────────────────────► TTI\n(page visible)                        (page usable)\n     │◄─── JS downloads + hydrates ──►│</code>\n        </deckgo-highlight-code>\n<h3 id=\"modern-solutions\" style=\"position:relative;\"><a href=\"#modern-solutions\" aria-label=\"modern solutions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Modern solutions</h3>\n<ul>\n<li><strong>Partial Hydration</strong> — only hydrate interactive components (Astro Islands)</li>\n<li><strong>Progressive Hydration</strong> — hydrate as components enter the viewport</li>\n<li><strong>Resumability</strong> — skip hydration entirely by serializing state (Qwik)</li>\n</ul>\n<hr>\n<h2 id=\"all-methods-compared\" style=\"position:relative;\"><a href=\"#all-methods-compared\" aria-label=\"all methods compared permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>All Methods Compared</h2>\n<div class=\"mermaid\">\nquadrantChart\n    title Speed vs SEO — Where each method lands\n    x-axis Slow Initial Load --> Fast Initial Load\n    y-axis Poor SEO --> Great SEO\n    quadrant-1 Ideal\n    quadrant-2 Good for content\n    quadrant-3 Limited use\n    quadrant-4 App-focused\n    CSR: [0.40, 0.15]\n    SSR: [0.58, 0.88]\n    SSG: [0.92, 0.92]\n    Hybrid SSR+SSG: [0.75, 0.88]\n</div>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>CSR</th>\n<th>SSR</th>\n<th>SSG</th>\n<th>Hybrid (SSR+SSG)</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>First Load Speed</strong></td>\n<td>🔴 Slow</td>\n<td>🟡 Medium</td>\n<td>🟢 Fast</td>\n<td>🟢 Fast</td>\n</tr>\n<tr>\n<td><strong>SEO</strong></td>\n<td>🔴 Poor</td>\n<td>🟢 Excellent</td>\n<td>🟢 Excellent</td>\n<td>🟢 Excellent</td>\n</tr>\n<tr>\n<td><strong>Data Freshness</strong></td>\n<td>🟢 Real-time</td>\n<td>🟢 Per-request</td>\n<td>🔴 Build-time</td>\n<td>🟡 Configurable</td>\n</tr>\n<tr>\n<td><strong>Server Cost</strong></td>\n<td>🟢 Low</td>\n<td>🔴 High</td>\n<td>🟢 None</td>\n<td>🟡 Medium</td>\n</tr>\n<tr>\n<td><strong>Scalability</strong></td>\n<td>🟡 Medium</td>\n<td>🔴 Harder</td>\n<td>🟢 Excellent</td>\n<td>🟢 Good</td>\n</tr>\n<tr>\n<td><strong>Interactivity</strong></td>\n<td>🟢 Rich</td>\n<td>🟡 After hydration</td>\n<td>🟡 After hydration</td>\n<td>🟡 After hydration</td>\n</tr>\n<tr>\n<td><strong>Complexity</strong></td>\n<td>🟢 Simple</td>\n<td>🟡 Medium</td>\n<td>🟢 Simple</td>\n<td>🔴 Complex</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2 id=\"when-to-use-each-method\" style=\"position:relative;\"><a href=\"#when-to-use-each-method\" aria-label=\"when to use each method permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>When to use each method</h2>\n<p><strong>Use CSR when:</strong></p>\n<ul>\n<li>Building authenticated apps (dashboards, admin panels)</li>\n<li>Data changes frequently and SEO doesn't matter</li>\n<li>You need rich, complex client-side interactions</li>\n</ul>\n<p><strong>Use SSR when:</strong></p>\n<ul>\n<li>Pages need fresh data on every request</li>\n<li>SEO is critical and content changes frequently</li>\n<li>You're building e-commerce or social platforms</li>\n</ul>\n<p><strong>Use SSG when:</strong></p>\n<ul>\n<li>Content doesn't change often (blogs, docs, portfolios)</li>\n<li>You want maximum speed and zero server cost</li>\n<li>Pages are the same for every user</li>\n</ul>\n<p><strong>Use Hybrid (SSG + SSR + ISR) when:</strong></p>\n<ul>\n<li>Some pages are static, some are dynamic</li>\n<li>You need incremental rebuilds (ISR) to keep static pages fresh</li>\n<li>You want per-page control over the rendering strategy</li>\n</ul>\n<hr>\n<blockquote>\n<p><strong>The modern consensus:</strong> Most production apps benefit from a hybrid approach. Frameworks like Next.js, Nuxt.js, and SvelteKit let you choose the rendering strategy <strong>per page</strong>, so you can statically generate your marketing pages while server-rendering your product listings and client-rendering your dashboard.</p>\n</blockquote>","wordCount":{"words":803},"frontmatter":{"title":"Rendering Methods Explained: CSR, SSR, SSG & Hydration","date":"March 19, 2026","description":"A deep dive into the main frontend rendering strategies — Client-Side Rendering, Server-Side Rendering, Static Site Generation, and Hydration — with diagrams for each.","lang":"en"},"tableOfContents":"<ul>\n<li>\n<p><a href=\"#client-side-rendering-csr\">Client-Side Rendering (CSR)</a></p>\n<ul>\n<li><a href=\"#how-csr-works-step-by-step\">How CSR works step by step</a></li>\n<li><a href=\"#pros-and-cons\">Pros and Cons</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#server-side-rendering-ssr\">Server-Side Rendering (SSR)</a></p>\n<ul>\n<li><a href=\"#how-ssr-works-step-by-step\">How SSR works step by step</a></li>\n<li><a href=\"#pros-and-cons-1\">Pros and Cons</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#static-site-generation-ssg\">Static Site Generation (SSG)</a></p>\n<ul>\n<li><a href=\"#how-ssg-works-step-by-step\">How SSG works step by step</a></li>\n<li><a href=\"#pros-and-cons-2\">Pros and Cons</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#hydration\">Hydration</a></p>\n<ul>\n<li><a href=\"#the-hydration-problem\">The Hydration problem</a></li>\n<li><a href=\"#modern-solutions\">Modern solutions</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#all-methods-compared\">All Methods Compared</a></p>\n</li>\n<li>\n<p><a href=\"#when-to-use-each-method\">When to use each method</a></p>\n</li>\n</ul>"},"translations":{"nodes":[]},"previous":{"fields":{"slug":"/password-seguridad/"},"frontmatter":{"title":"Seguridad de Contraseñas - Cómo se hackean y cómo protegerte"}},"next":{"fields":{"slug":"/metodos-de-renderizado/"},"frontmatter":{"title":"Métodos de Renderizado: CSR, SSR, SSG e Hidratación"}}},"pageContext":{"id":"64505be7-79ae-5dd9-ab3f-8c4e5501236e","previousPostId":"2f83cf33-e6f1-54bc-94d5-753ee0723f8a","nextPostId":"59e596a5-eb08-5936-9cf4-6018d73d3d8d","baseSlug":"/rendering-methods/"}},"staticQueryHashes":["712016698"],"slicesMap":{}}