React Server Components and Server Actions: The New Boundary
Server Components run outside the client bundle and send their result to the browser instead of their code. Server Functions move writes to the server – both are implemented by a suitable framework or bundler.
React Server Components and Server Actions: The New Boundary
Error: You're importing a component that needs `useState`.
This React Hook only works in a Client Component.
To fix, mark the file (or its parent) with the "use client" directive.
For many people, this message is their first contact with React Server Components, and the usual reflex is: put "use client" in the first line, error gone, move on. The build is green again, and the real question has been skipped. The message isn’t a configuration error, though. It asks which side of a boundary this piece of UI belongs on – and the answer reaches far beyond the file where the directive ends up.
When you move an architectural boundary, you always move more than code: you also move where testing happens, what has to be deployed and which team owns which part of the UI. That is the trade-off this is really about. Faster delivery and a smaller bundle are the visible gain. The real effect lies underneath: shorter paths from data access to display, less friction at the seam between the two worlds – paid for with a boundary that you now have to draw and defend deliberately.
Editorial note (July 2026): React 19 stabilized Server Components as a component model. The interfaces that frameworks and bundlers use to implement them, however, still don’t follow the usual semver stability within React 19.x. React alone therefore doesn’t yet provide a complete production architecture for them; the examples in this post use the Next.js App Router. Server Components can also run at build time or per request. Only the dynamic variant needs a runtime server.
This is where many people get stuck at first: you look for a new hook and instead run into a boundary that has moved – with consequences for testing, operations and team structure. From now on, the framework no longer decides for you which part of the UI stays on the server and which goes to the browser. That is what this post is about.
What a Server Component really is#
A Server Component runs in an environment outside the client bundle: at build time or on a server per request. There it can render with direct access to the database, file system or internal services and then send only its result to the browser. Not its code. That is the key sentence. For a component that merely displays something, no component code of its own ends up in the client bundle. The browser gets a description of what it should display, not the component that produced this description.
That is a different use of the word “render” than you are used to. This is why it’s worth going back to an earlier post: in How React renders the tree I showed that rendering in React is only a calculation anyway – a function that turns inputs into a description of the tree, which React then compares with the last state. But if rendering is only a calculation, the question arises immediately: where does this calculation run? This is exactly where Server Components come in. They permanently move part of this calculation to the server instead of doing it in the browser as before.
The difference from SSR that almost everyone mixes up#
One point needs setting straight here, because it reliably causes confusion: Server Components are not the same as server-side rendering, and the difference is not cosmetic.
Classic SSR takes perfectly normal client components and renders them once on the server to HTML so that the browser sees something right away. After that, though, the server still sends the component code along, and hydration runs in the browser: React attaches itself to the delivered HTML, runs the same component again and makes it interactive. So the code goes along – SSR is an early first impression, not a way to save JavaScript. In the end, the component exists twice: once as HTML from the server, once as runnable code in the browser.
A Server Component, by contrast, never exists in the client bundle. There is nothing to hydrate, because there is no second execution in the browser. The server has done the calculation, the result is there, and that’s the end of the story for this part of the tree. SSR answers the question “when does the user see something for the first time”. Server Components answer the other question: “does this code ever need to go to the browser at all”. For pure display, the answer is now no.
flowchart TB
subgraph Server
SC["Server Component<br/>reads data directly"]
end
subgraph Browser
UI["finished result<br/>is displayed"]
Island["Client island<br/>(hooks, events)"]
end
DB[("Database / service")]
SC -->|await| DB
SC -->|only the result,<br/>no code| UI
SC -.->|embeds| IslandThe boundary is called "use client"#
If Server Components are the normal case, you need a marker for the exception – for the place where interactivity begins. This marker is the "use client" directive at the top of a file. Everything above this boundary runs on the server: loading data, displaying it, building structure, no state. From the directive on, you are in browser land with everything that comes with it – useState, useEffect, event handlers, access to window.
What matters is the direction in which these two worlds fit together. A Server Component may contain Client Components as children – you sprinkle islands of interactivity into an otherwise static, server-rendered page. The other way around is restricted: a Client Component can’t simply import a Server Component, because the server code would then have to end up in the browser after all. It can only embed a Server Component as a passed-in children slot – the server renders the child, the client component receives the finished result and wraps its interactive shell around it. This one rule explains most of the error messages people stumble over at the start.
flowchart TB Page["Server Component (page)<br/>loads data, displays it"] Page --> List["Server Component<br/>invoice list"] Page --> Button["Client island<br/>"use client": button with onClick"] Button -->|allowed as children| Slot["Server content<br/>as slot"]
Server Components in practice#
Because a Server Component only runs on the server, it may do something that never worked in the browser: it may be async and use await directly in its body. Loading data then happens without useEffect, without a loading flag, without the whole apparatus – you write it down as if it were a normal function that just happens to be able to access a database.
// invoices-page.jsx — a Server Component, no "use client" here
import { db } from "@/lib/db";
import { PayButton } from "./pay-button";
export default async function InvoicesPage() {
const invoices = await db.invoice.findMany({ where: { open: true } });
return (
<section>
<h1>Open invoices: {invoices.length}</h1>
<ul>
{invoices.map((invoice) => (
<li key={invoice.id}>
{invoice.title} — {invoice.amount} €
<PayButton invoiceId={invoice.id} />
</li>
))}
</ul>
</section>
);
}
Two things deliberately sit side by side here. The await db.invoice.findMany(...) accesses the database directly – this code never leaves the server, there is no API route in between and no loading state in the browser. And PayButton is an embedded client island: everything that needs a click moves into its own file with "use client".
// pay-button.jsx
"use client";
import { useState } from "react";
export function PayButton({ invoiceId }) {
const [busy, setBusy] = useState(false);
return (
<button disabled={busy} onClick={() => setBusy(true)}>
{busy ? "Paying…" : "Pay"}
</button>
);
}
What doesn’t work in a Server Component is just as instructive: no useState, no useEffect. In this environment there is no local client state that you keep across clicks. A Server Component can render again on a later request or a new server execution; but it doesn’t handle direct browser interaction. Everything that should react immediately in the browser to a click belongs in a client island beyond the boundary.
Server Actions: moving writes back to the server#
Server Components solve reading and displaying. For writing, there are Server Functions, often called Server Actions, marked with the "use server" directive. These are functions that run on the server but are called from the client through the framework’s integration – most directly as the action of a <form>. In the application, you don’t build your own API route or your own request format for this call. However, transport, serialization and the security boundary are not handled by React as a runtime alone, but by the framework you use.
// invoice-actions.js
"use server";
import { db } from "@/lib/db";
import { revalidatePath } from "next/cache";
export async function payInvoice(formData) {
const id = formData.get("invoiceId");
await db.invoice.update({ where: { id }, data: { open: false } });
revalidatePath("/invoices");
}
It is called directly from the form. So that the user gets feedback while the action is running, there are two hooks made exactly for this: useActionState bundles the call with its result and a pending flag, and useFormStatus reads the pending state of the surrounding form in a child element.
// pay-form.jsx
"use client";
import { useActionState } from "react";
import { useFormStatus } from "react-dom";
import { payInvoice } from "./invoice-actions";
function SubmitButton() {
const { pending } = useFormStatus();
return (
<button type="submit" disabled={pending}>
{pending ? "Paying…" : "Pay invoice"}
</button>
);
}
export function PayForm({ invoiceId }) {
const [state, formAction] = useActionState(payInvoice, null);
return (
<form action={formAction}>
<input type="hidden" name="invoiceId" value={invoiceId} />
<SubmitButton />
</form>
);
}
The appeal lies in how little is written here. No fetch, no manual POST, no hand-built endpoint, no serialization. You call a function that happens to run on the server, and the pending state for the UI comes along for free.
flowchart LR
Form["Form in the browser<br/>action = payInvoice"]
Form -->|Submit| Action["Server Action<br/>"use server""]
Action -->|writes| DB[("Database")]
Action -->|revalidatePath| Fresh["Server re-renders<br/>the affected view"]
Fresh -->|new result| FormWhat this means for the series#
This new boundary shifts another one I have already written about. In Client State vs. Server Cache the core point was: most of what looks like state is really borrowed server cache that you only keep temporarily in the browser. Server Components shift this boundary once more. A large part of the data loading for display, which used to require a cache library in the browser, now moves to the server – there the Server Component reads directly and sends only the result. The need to track the same data in the client shrinks accordingly.
That doesn’t mean server state libraries become unnecessary. As soon as things get interactive – data that changes after a click without reloading the whole page – the cache in the browser still makes sense. But the split shifts: less display in the client, more on the server. Staggered delivery is handled by Suspense, which streams the server-rendered parts to the browser piece by piece.
What the shifted boundary does to testing, operations and teams#
So far this sounds like a clean technical reshuffle. It gets interesting, though, where this boundary meets the way a team works, tests and ships. Because an architectural boundary is never just a line of code. It decides where complexity arises – and complexity always comes with a bill.
Let’s start with testability, because that is where it shows most clearly what the shift costs and what it saves. A pure display component that used to load data in the browser was surprisingly laborious to test: mock fetch, play through the loading state, reproduce the error path, wait for the re-render after the data arrives. As a Server Component, this whole apparatus disappears. The component is an async function that receives data and returns a description – testable like a function, without a browser environment, without timing. The price sits on the other side of the boundary: the direct await db.invoice.findMany(...) in the component body weaves data access and presentation together, and the component now wants to see a database for a test. So testing moves rather than disappears: you tend to check Server Components with integration tests against a real or in-memory data source, and the interactive islands still as isolated client tests. If you draw this split deliberately, you win; if you ignore it, you build hard-to-test hybrids.
In deployment, the character of the application shifts as soon as Server Components run per request or Server Functions write. Client-only React could end up as a bundle of static files behind a CDN; pure Server Components executed at build time can also be delivered statically. The dynamic variant, however, needs a running process with access to the database and internal services. That brings proximity – data access sits right next to the component, without a separate API layer in between – and operational responsibility: server capacity, runtime errors beyond the browser and a boundary between public and internal code that becomes a security boundary. The gain is a shorter chain from click to persistence. The cost is an operational surface that wasn’t there before.
And then there is team structure, the point that is easiest to overlook and most expensive to pay for. In the classic split there was a hard seam: frontend builds the UI, backend delivers the API, and in between sits a contract of endpoints and formats. This seam was friction, but also a clear boundary of responsibility. Server Components and Server Actions dissolve it – data access moves into the component, writing into a function next to it, and the contract of API routes disappears. For a team that works across the full depth, this is a noticeable reduction in friction: shorter paths, less coordination about endpoints, less code that only carries data back and forth. For two separate teams with a clean frontend-backend split, it is the opposite: the boundary where they handed over responsibility is gone, and the new one runs right through the middle of the UI. Whether Server Components are a gain or a source of conflict therefore depends less on the technology than on the organization.
This leads to the decision criteria I apply in projects. Server Components pay off when the team works across the full depth and the frontend-backend seam has so far been more burden than protection, when a running server is part of operations anyway, and when the UI is data-heavy and not very interactive. They cost more than they bring when two teams deliver along a deliberately drawn API boundary, when operations are supposed to stay purely static, or when the application consists almost entirely of interactive islands. So the question is not “is the technology good” but “does the shifted boundary fit how we build, test and ship”.
An honest assessment: new and with friction#
I don’t want to sugarcoat this. Server Components are new, and they come with friction. You have to really understand the boundary between server and client, or you produce exactly the errors I described above – an import across the boundary, a hook on the wrong side, a data access that suddenly is supposed to end up in the browser. The ecosystem is still in flux: the widespread implementation today is the Next.js App Router, other frameworks are catching up, and some libraries first have to learn where they belong in this world.
And not every application needs this. A highly interactive dashboard that runs almost entirely in the browser anyway gains little if you force it through the server-client boundary. Where Server Components clearly pay off, on the other hand: for data-heavy, largely static UIs where a lot is displayed and little is clicked; when the client bundle noticeably weighs you down and you want to get rid of display code that has no business being in the browser; and where server-delivered HTML matters for search engines and the first impression. That is an honest trade-off, not an obligation.
The real decision#
If one thought from this post should stick, it is this one: Server Components are not a faster way to render. They are a decision about location. For every part of the UI, you now ask first: does this stay on the server – because it only reads and displays – or does it belong in the browser because a human interacts with it? The "use client" and "use server" directives are nothing more than the visible markers of this one decision.
If you draw the boundary deliberately, you reap the effect that lies beneath the technology: shorter paths from data access to display and therefore faster cycles, less friction at the dissolved frontend-backend seam, and testability that splits cleanly into server-side integration tests and client islands. If you blur the boundary, you get the opposite – hard-to-test hybrids, unclear responsibilities, operational load without a return. The difference doesn’t lie in the framework. It lies in whether the shifted boundary fits how a team builds, tests and ships – and whether you keep it clear enough afterwards to defend it. This question is what matters – long before you look up the first hook.
Further reading#
- Repository introduction-react (chapters server-components, server-actions; App Router examples): https://github.com/mikebild/introduction-react
- React, “Server Components”: https://react.dev/reference/rsc/server-components
- React, “Server Functions”: https://react.dev/reference/rsc/server-functions
- Next.js, App Router: https://nextjs.org/docs/app
Revised and translated from German with the help of AI.