Improving Performance with Server-Side Rendering: Concepts and Implementation
A plain guide to server-side rendering: how the request lifecycle differs from client-side rendering, what hydration is, and how a Next.js 16 page with Server Components and Suspense streams its slow parts. It also covers what crawlers receive, why TTFB can rise, hydration mismatches, and when client-side or static rendering is the better choice. The example app was built and timed.

A page that shows a blank screen and then a spinner loses readers before your content appears. Server-side rendering is one of the main fixes. This guide is for developers who have built single-page apps and want to know what changes when the server renders the first view. You'll see the request lifecycle for both models, build a small streaming page in Next.js, and learn when server rendering is the wrong choice.
This is part 27 of the Frontend & JavaScript Fundamentals series. The previous part, webpack and Babel from scratch, showed how your code becomes bundles. This part looks at where those bundles run.
Key takeaways
- With SSR the browser gets real HTML first, so content can paint before any JavaScript runs. Hydration then makes it interactive.
- In Next.js, wrap slow parts of a page in
<Suspense>. The rest of the page streams at once, and the slow part arrives later in the same response. - SSR costs server time and can raise Time to First Byte. Static rendering is often better for pages that rarely change.
Client-side rendering and its bottleneck
Server-side rendering (SSR) means rendering an app on the server to send HTML, rather than JavaScript, to the client. That is web.dev's definition. Client-side rendering (CSR) is the opposite: the browser runs JavaScript that builds the page by changing the DOM.
A typical client-rendered app loads like this:
- The browser requests the page and gets an almost empty HTML shell.
- It downloads the JavaScript bundle.
- It runs the bundle, and the framework starts.
- The app calls an API for data.
- The content finally appears.
Each step waits for the one before it. Here is the client-side version of a profile page, so you can see the chain in code. It assumes an API route at /api/profile that returns the user and the activity list.
// app/profile-csr/page.js: the client-side version, for comparison
'use client';
import { useEffect, useState } from 'react';
export default function ProfilePageCSR() {
const [data, setData] = useState(null);
useEffect(() => {
fetch('/api/profile')
.then((res) => res.json())
.then(setData);
}, []);
if (!data) return <p>Loading...</p>;
return (
<main className="profile">
<h1>Welcome back, {data.user.name}</h1>
<ul>
{data.activities.map((item) => (
<li key={item.id}>{item.action}</li>
))}
</ul>
</main>
);
}
In a test build, fetching this page with curl showed that the HTML held only "Loading...". The name and the list exist only after the browser runs the script and the API answers. web.dev also notes that client-rendered apps tend to need more JavaScript as they grow, which can hurt Interaction to Next Paint (INP).
How server-side rendering changes the order
With SSR, the server does the work before it answers:
- The browser requests the page.
- The server fetches the data and renders the components to HTML.
- The browser receives a complete HTML document and paints it.
- Hydration runs: React attaches event handlers to that HTML so it becomes interactive.
The Next.js docs describe the same split. The HTML gives a fast, non-interactive preview, and the JavaScript hydrates it. The user sees content at step 3, not after the whole JavaScript chain.
| Model | What the browser gets first | Trade-off | When to use |
|---|---|---|---|
| Client-side rendering | An empty shell and a script | Slow first paint; more JavaScript as the app grows | Dashboards behind a login |
| Server-side rendering | Full HTML per request | Server cost; TTFB depends on server work | Personal or fast-changing public pages |
| Static rendering | HTML built ahead of time | Content is only as fresh as the last build | Blogs, docs, marketing pages |
Build a streaming page in Next.js
In the Next.js App Router, pages and layouts are Server Components by default, according to the Next.js docs. A Server Component can be an async function and fetch data directly. Start with two stand-in data functions, one fast and one slow:
// lib/data.js: stand-ins for a database or API
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
export async function getUser() {
await sleep(200);
return { id: 'u1', name: 'Asha', plan: 'Pro' };
}
export async function getRecentActivity(userId) {
await sleep(2000); // a slow query
return [
{ id: 'a1', action: `${userId} updated a report` },
{ id: 'a2', action: `${userId} invited a teammate` },
];
}
Now the page. The slow activity feed sits inside a <Suspense> boundary:
// app/profile/page.js: a Server Component (the default in the App Router)
import { Suspense } from 'react';
import { connection } from 'next/server';
import { getUser, getRecentActivity } from '@/lib/data';
export default async function ProfilePage() {
await connection(); // render on every request, not once at build time
const user = await getUser();
return (
<main className="profile">
<h1>Welcome back, {user.name}</h1>
<p>Plan: {user.plan}</p>
<Suspense fallback={<p>Loading activity...</p>}>
<ActivityFeed userId={user.id} />
</Suspense>
</main>
);
}
async function ActivityFeed({ userId }) {
const activities = await getRecentActivity(userId);
return (
<ul>
{activities.map((item) => (
<li key={item.id}>{item.action}</li>
))}
</ul>
);
}
Checked against next@16.4.3, react@19.3.1 and react-dom@19.3.1 on Node.js 22, 2026-10-29. The @/lib/data import assumes lib/ sits next to app/ and that jsconfig.json has "compilerOptions": { "paths": { "@/*": ["./*"] } }. If you chose a src/ folder in create-next-app, @/* points to ./src/* instead.
Three details matter here:
connection()tells Next.js to wait for a real request. The stand-in data doesn't read cookies or headers, so without this line a testnext buildprerendered/profileonce as a static page. Theconnection()reference describes this use.className, notclass. JSX usesclassName. The earlier version of this post usedclass, which React warns about.- No data library in the browser bundle. Server Components keep their data code on the server. The Next.js docs list "reduce the amount of JavaScript sent to the browser" as a reason to use them.
What streaming does
Without the boundary, the whole page waits for the slowest query. The Next.js fetching guide says a slow request blocks the whole route until all the data is fetched. With the boundary, React sends the heading and the fallback first. When the feed is ready, it streams that HTML into the same response, with a small script that swaps it in.
In a test build served with next start, the first chunk arrived after about 0.2 seconds and already held the heading and "Loading activity...". The full response ended after about 2.2 seconds, when the slow query finished. Your numbers will differ; the shape is the point.
Keep the main content outside the boundary
The Next.js streaming guide warns that an element inside a Suspense boundary can't paint until its content is swapped in. If your Largest Contentful Paint element is a hero image or main heading, keep it above the boundary, as the heading is here.
What search engines receive
Google processes JavaScript pages in three phases: crawling, rendering and indexing. Its JavaScript SEO guide says a page may wait in the render queue for a few seconds, or longer. The same guide still calls server-side rendering or pre-rendering "a great idea", because it makes sites faster for users and crawlers, and not all bots can run JavaScript.
Streaming doesn't hide content from crawlers. The Next.js docs say bots get the fully rendered page instead of a streamed one. In a test build, a request with a Googlebot user agent received the activity list in the response.
When not to use SSR
SSR is not free. Weigh these costs first.
- Server time and cost. Every request runs your components on a server. web.dev notes that rendering on the server takes time and can raise your Time to First Byte (TTFB).
- Streaming needs the whole path to cooperate. The Next.js streaming guide notes that Nginx buffers responses by default, and some CDNs and serverless platforms do too. A buffering layer turns a stream back into one late response.
- Hydration mismatches. React expects the browser's first render to match the server HTML exactly. The React docs list common causes, such as checks like
typeof window !== 'undefined'or different data on each side.
The last one is easy to hit with dates. Hydration only happens in Client Components, so this file starts with 'use client':
'use client';
// Mismatch: the server and the browser render different times
export function LastSeen() {
return <p>Rendered at {new Date().toLocaleTimeString()}</p>;
}
// Fix for one unavoidable difference: tell React it is expected
export function LastSeenFixed() {
return (
<p suppressHydrationWarning>
Rendered at {new Date().toLocaleTimeString()}
</p>
);
}
The React docs call suppressHydrationWarning an escape hatch that works one level deep. Use it only for values like timestamps. For bigger differences, fix the data so both sides render the same thing.
As a rule of thumb: use static rendering for pages that rarely change, SSR for pages that need live or personal data, and CSR for app screens behind a login. web.dev gives similar advice and suggests measuring before you choose.
Next in the series, frontend deployment strategies covers where an SSR app runs once it leaves your laptop, and why it needs a server that a static site doesn't.
Frequently asked questions
Is SSR always faster than client-side rendering?
No. SSR usually shows content sooner, but the server has to do work before it answers, which can raise TTFB. For pages that rarely change, static rendering often wins because the HTML is ready before anyone asks for it.
What is hydration?
Hydration is the step where React attaches event handlers to HTML the server already rendered. Until it finishes, the page is visible but buttons may not respond. The Next.js docs describe it as making static HTML interactive.
Does streaming hurt SEO?
Not in Next.js, according to its docs. Bots and crawlers get the fully rendered page instead of a stream. In a test build, a request with a Googlebot user agent received the complete activity list.
Do I need Next.js for server-side rendering?
No. React, Vue and other frameworks can render on the server without it. A framework such as Next.js adds routing, streaming and data patterns, so you don't wire them up yourself.
Why does my Next.js page not render per request?
If a page reads no request data, such as cookies or headers, Next.js may prerender it at build time. Call await connection() from next/server before the work that should run on each request.
Sources
Verified against the sources below on October 29, 2026. Products and docs change often: check the linked sources if something looks different.
All 30 parts in this series
- Part 01Overcoming the Daunting Start: A Strategic Roadmap for New Frontend Developers
- Part 02Beyond the Tags: Mastering HTML Architecture for Product-Based Roles
- Part 03From Selectors to BEM: CSS Concepts You Must Know for Professional Projects
- Part 04Mastering the Primitives: A Builder's Guide to JavaScript Data Types and Functions
- Part 05Demystifying Scope and Closure: Key Concepts for Writing Robust JavaScript
- Part 06Beyond Frameworks: Practical DOM Manipulation Techniques for High-Performance UIs
- Part 07From Prototypes to ES6 Classes: Understanding JavaScript's Object-Oriented Nature
- Part 08Architecting Scalable JavaScript: OOP Principles & Design Patterns
- Part 09Mastering the Metal: Essential Web APIs & Browser Internals for Frontend Engineers
- Part 10Understanding the JavaScript Runtime: Event Loop, Call Stack, and Task Queue Explained
- Part 11Mastering Asynchronous Operations with JavaScript Promises: A Builder's Guide
- Part 12Modern Async Patterns: Making Asynchronous Code Readable with Async/Await and Generators
- Part 13Inside the V8 Engine: A Deep Dive into JavaScript Execution
- Part 14Demystifying CORS, HTTP, and Security: A Builder’s Guide
- Part 15REST vs. GraphQL: A Frontend Engineer’s Reality Check
- Part 16Secure Frontend Auth: The Definitive Guide to JWTs, Cookies, and Storage Strategies
- Part 17Why TypeScript Matters: Adding Type Safety to Your JavaScript Projects
- Part 18Getting Started with React: Deconstructing JSX and Component Architecture
- Part 19React Architecture: Mastering State and Props in Class vs. Functional Components
- Part 20Mastering React Hooks: From useState to Building a Production-Ready Custom Hook
- Part 21React State Management: Context API vs. Redux & Building a Theme Switcher
- Part 22React Architecture: Advanced Navigation and Data Flow Patterns
- Part 23Automated Testing in React: Unit Testing with Jest and React Testing Library
- Part 24Mastering Chrome DevTools: Debugging Techniques That Save Hours of Development Time
- Part 25Automating Code Quality: The Modern Stack with ESLint, Prettier, and Husky
- Part 26Demystifying the Build Pipeline: A Deep Dive into Webpack and Babel Configuration
- Part 27Improving Performance with Server-Side Rendering: Concepts and Implementation
- Part 28From Development to Production: A Builder's Guide to Frontend Deployment Strategies
- Part 29Introduction to Micro Frontends: Building Scalable Architectures
- Part 30The Frontend Architecture: From Junior Developer to Tech Lead



Comments
Loading comments...