<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mhamzashaikh on Medium]]></title>
        <description><![CDATA[Stories by mhamzashaikh on Medium]]></description>
        <link>https://medium.com/@mhamzashaikh?source=rss-365ed6fd12ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4Rh69HAyJQOfMyZY0Q20YA.png</url>
            <title>Stories by mhamzashaikh on Medium</title>
            <link>https://medium.com/@mhamzashaikh?source=rss-365ed6fd12ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:08:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhamzashaikh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Server-Side Rendering in Next.js: A Practical Guide]]></title>
            <link>https://medium.com/@mhamzashaikh/understanding-server-side-rendering-in-next-js-a-practical-guide-d77652a62437?source=rss-365ed6fd12ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/d77652a62437</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[mhamzashaikh]]></dc:creator>
            <pubDate>Tue, 16 Dec 2025 08:42:35 GMT</pubDate>
            <atom:updated>2025-12-16T08:42:35.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gIABWLTnbgLBfigqVdvCVQ.png" /></figure><p>Server-side rendering (SSR) is often explained at a surface level, but many developers struggle to decide when it actually belongs in a production Next.js application. This article focuses on how SSR works internally, the problems it truly solves, and how to apply it intentionally rather than by default.</p><p>The goal is not to compare features, but to build a reliable understanding you can use when designing real systems.</p><h3>What Server-Side Rendering Really Means in Next.js</h3><p>In Next.js, <strong>server-side rendering</strong> means the HTML for a page is generated on the <strong>server for every incoming request</strong>.</p><p>This is different from:</p><ul><li><strong>Static generation</strong>, where HTML is created at <strong>build time</strong>.</li><li><strong>Client-side rendering</strong>, where HTML is assembled in the browser <strong>after JavaScript loads</strong>.</li></ul><p>With SSR:</p><ul><li>Data fetching happens on the server</li><li>React components render on the server</li><li>Fully rendered HTML is sent to the client</li><li>React hydrates the page to make it interactive</li></ul><p>The key point is that <strong>SSR is request-bound</strong>. Every request triggers a new render cycle.</p><h3>Why SSR Exists in Next.js</h3><p>SSR is not primarily about performance. It exists to solve three specific problems:</p><h3>1. Request-specific data</h3><p>Some data cannot be known ahead of time:</p><ul><li>Authenticated user context</li><li>Cookies or headers</li><li>Geo-based content</li></ul><p>SSR allows the server to render HTML using <strong>request-scoped data</strong>.</p><h3>2. SEO for dynamic content</h3><p>Search engines can index JavaScript, but dynamic pages still benefit from pre-rendered HTML:</p><ul><li>Product pages with live inventory</li><li>User-generated content</li><li>Marketplaces and listings</li></ul><p>SSR ensures crawlers receive meaningful content <strong>immediately</strong>.</p><h3>3. Consistent first paint</h3><p>With SSR, users see structured content before JavaScript finishes loading. This improves <strong>perceived performance</strong>, even if total load time is similar.</p><h3>How SSR Has Evolved in Next.js (v14, v15, v16)</h3><h3>Next.js 14 — Pages Router SSR</h3><p>In the traditional Pages Router, SSR is implemented using getServerSideProps.</p><pre>export async function getServerSideProps(context) {<br>  const res = await fetch(&#39;https://api.example.com/dashboard&#39;, {<br>    headers: {<br>      cookie: context.req.headers.cookie<br>    }<br>  })</pre><pre>  const data = await res.json()</pre><pre>  return {<br>    props: { data }<br>  }<br>}</pre><ul><li>Runs on every request</li><li>Executes only on the server</li><li>Has access to headers, cookies, and query params</li><li>Blocks the response until data is resolved</li><li><strong>Hide API calls from the client</strong>, improving security</li></ul><h3>Next.js 15 — App Router SSR</h3><p>With the App Router, server rendering is <strong>default</strong>. Data fetching happens directly in components:</p><pre>const data = await fetch(&#39;https://api.example.com/dashboard&#39;, {<br>  cache: &#39;no-store&#39;<br>})</pre><ul><li>Components can be server-only or client-only</li><li>Data fetching is colocated with UI</li><li>Rendering is streaming by default</li><li>Caching becomes <strong>explicit</strong> rather than implicit</li><li><strong>Server-only components can safely fetch sensitive APIs</strong> without exposing them to the client</li></ul><p>SSR becomes <strong>less of a feature and more of an execution context</strong>.</p><h3>Next.js 16 — Advanced Caching and Streaming</h3><p>Next.js 16 further improves SSR with <strong>flexible caching strategies</strong> and <strong>React Server Components</strong>:</p><ul><li>force-cache for static-like behavior</li><li>no-store for per-request SSR</li><li>Revalidation for hybrid static/SSR</li></ul><h3>When SSR Is the Right Tool</h3><p>SSR makes sense when the page output depends on the request itself. Typical use cases:</p><ul><li>Authenticated dashboards</li><li>Role-based UI rendering</li><li>Personalized recommendations</li><li>Admin interfaces</li><li>Real-time pricing or availability</li></ul><p>In these cases, static generation would either leak data or become overly complex.</p><h3>When SSR Becomes a Liability</h3><p>SSR should <strong>not</strong> be used by default. Avoid SSR when:</p><ul><li>Content is identical for all users</li><li>Data changes infrequently</li><li>Pages receive high traffic with low variance</li></ul><p>Each SSR request consumes server compute. At scale, unnecessary SSR increases <strong>cost and latency</strong>.</p><p>Static generation with revalidation often delivers better results with less complexity.</p><h3>Performance Implications Developers Often Miss</h3><p>SSR performance is more than just server speed. Hidden costs include:</p><ul><li>Cold starts in serverless environments</li><li>Slow upstream APIs blocking render</li><li>Serialization overhead for large props</li><li>Hydration mismatch debugging</li></ul><p>A fast SSR page can still feel slow if <strong>hydration is heavy</strong> or <strong>client bundles are large</strong>.</p><h3>SSR in Real Production Architectures</h3><p>In mature Next.js systems, SSR is rarely used alone. Common patterns:</p><ul><li>Static marketing pages</li><li>SSR for authenticated flows</li><li>Client-side rendering for highly interactive tools</li><li>Edge rendering for lightweight personalization</li></ul><p>The best applications <strong>mix rendering strategies</strong> rather than standardizing on one.</p><h3>Practical Rule of Thumb</h3><p>Use server-side rendering only when:</p><ul><li>The request must influence the HTML</li><li>The data cannot be cached safely</li><li>SEO or first paint genuinely matters</li></ul><p>If none of these apply, SSR is usually unnecessary.</p><p>Next.js provides SSR <strong>not to encourage universal usage</strong>, but to give you <strong>control when static approaches break down</strong>.</p><p>Understanding this distinction is what separates <strong>framework usage from system design</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d77652a62437" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>