In short
React Server Components run only on the server or at build time, and their code is never sent to the browser. They can read data directly, which cuts client-side JavaScript. Client components, marked with use client, handle interactivity. This is different from server-side rendering, which sends HTML first and then hydrates all of it. In Next.js's App Router, components are server components by default.
The problem they solve
In a traditional React app, the browser downloads your component code, then runs it, and then often makes further requests for data. As apps grow, that means large downloads and slower loading.
Lots of that code never needed to run in the browser. A blog post's content, or a product description, doesn't change when you click on it. Server Components let this code run on the server and send only the result.
React's documentation defines them as components that render ahead of time, before bundling, in an environment separate from your client app.
A short example
// Server Component: the default in the Next.js App Router
import { db } from "./db";
import LikeButton from "./LikeButton";
export default async function Post({ id }) {
const post = await db.posts.find(id);
return (
<article>
<h1>{post.title}</h1>
<p>{post.body}</p>
<LikeButton postId={id} />
</article>
);
}
// LikeButton.js: a Client Component
"use client";
import { useState } from "react";
export default function LikeButton({ postId }) {
const [liked, setLiked] = useState(false);
return <button onClick={() => setLiked(!liked)}>{liked ? "Liked" : "Like"}</button>;
}
The Post component reads from the database directly, and its code and database library never reach the browser. Only the small button ships JavaScript.
Server Components vs server-side rendering
They're often confused, because both involve a server.
| Classic SSR | Server Components | |
|---|---|---|
| What the server produces | HTML from the whole page | A special payload describing the output |
| JavaScript sent to the browser | Code for all components | Only client components |
| Hydration | The whole page | Client components only |
| Direct database access | Only in special functions | Inside the component |
| Can use state and effects | Yes | No |
They can work together. In Next.js, Server Components still produce HTML for the first load. See what hydration is.
What goes where
| Use a Server Component for | Use a Client Component for |
|---|---|
| Fetching data | Click handlers, form inputs |
| Reading secrets or a database | useState, useEffect |
| Large libraries, such as Markdown parsers | Browser APIs, such as localStorage |
| Mostly static content | Live updates and animations that respond to input |
A useful rule: keep it on the server unless it needs interactivity. Then make the smallest part possible into a client component, such as the button, not the entire page.
The rules that trip people up
A client component can't import a server component directly. But it can receive one as children. That's how you nest them.
Props must be serialisable. You can't pass an ordinary function from a server component to a client component, as it has to travel across the network. (Server Actions are a special case.)
use client marks a boundary. Everything imported below it becomes part of the client bundle. Put it too high up, and you'll lose most of the benefits.
Browser APIs fail on the server. Using window in a server component will throw an error.
Caching can be confusing. Frameworks cache server output, and it's easy to show stale data. Next.js has changed its caching defaults between versions, so read the documentation for your version. See what Next.js is.
Security: this is where it matters
Because Server Components blur the line between server and client, mistakes can be serious.
- Don't pass whole objects to client components. If you pass a full user record, including an email or a password hash, it gets sent to the browser, even if you only display a name. Pass just what's needed.
- Protect secrets. Environment variables and tokens must stay on the server. In Next.js, anything with the
NEXT_PUBLIC_prefix is public. See how to handle secrets and API keys. - Treat Server Actions as public endpoints. They can be called directly, so check authentication and authorisation inside each one. Hiding a button doesn't protect anything.
- Validate all inputs, just as you would with any API.
- Keep your framework updated. In December 2025, the React team disclosed a critical vulnerability in Server Components that allowed remote code execution, and it was rated CVSS 10.0. Patches were released, but anything using these features needs prompt updates.
Benefits and limits
Benefits:
- Less JavaScript in the browser, which can help on slow phones
- Simpler data fetching, with no separate API for many pages
- Secrets and database code stay on the server
- Streaming, so that parts of a page can show up as they become ready
Limits:
- It adds complexity to your mental model
- You'll need a server or a framework that supports it, so it isn't a simple static bundle
- You're relying on a framework: Next.js is the most established option, with others catching up
- Debugging across the boundary may be harder
- Highly interactive apps benefit less, because much of the page has to be client-side anyway
Do you need them?
They're a good fit for content-heavy apps with some interactivity: e-commerce, dashboards with lots of read-only data, and documentation or marketing sites built in React.
They may not be for highly interactive tools such as editors, or apps that are entirely behind a login where SEO and first-load speed matter less. A simple client-side app built with Vite might be easier.
And you may not need React at all. If your site is mostly content, then consider Astro, or plain HTML. See why your site doesn't need a framework.
Using them with AI tools
Coding agents often generate Server Components by default in Next.js projects, and they can make mistakes at the boundary: passing too much data, adding use client to everything, or forgetting to check authorisation in Server Actions. Check these points when you review.
Measure the outcome as well. Open your browser's network tab to see how much JavaScript your page really ships, and track real-user speed. See how to measure real user performance.
If you'd like help deciding on the right architecture for your React app, book a call.
Common questions
What are React Server Components?
They're React components that run only on the server, or at build time. Their code isn't sent to the browser, so they can use databases and secrets directly and can reduce the amount of JavaScript that a page needs.
What is the difference between Server Components and SSR?
SSR renders the page to HTML on the server, but sends all component code to the browser for hydration. Server Components never send their own code, and only client components hydrate. The two are often used together.
When should I use use client?
Use it for components that need interactivity, state, effects or browser APIs, such as a button, form input or animation. Keep it as low in the tree as possible, because everything it imports joins the client bundle.
Are Server Components secure?
They help keep secrets on the server, but they don't make an app secure automatically. Avoid passing whole records to client components, check authorisation in Server Actions, and keep your framework updated, as serious vulnerabilities have been discovered.