Stop guessing where the server/client boundary belongs. A mental model, composition patterns and real code for React Server Components in the Next.js App Router.

Francis K Njenga
Senior Developer
React Server Components (RSC) are the biggest shift in React's mental model since hooks — and the source of most confusion in App Router codebases. Teams either sprinkle "use client" on every file "to be safe" (and ship a huge bundle), or fight the framework trying to make interactive widgets render on the server. Both failure modes come from the same gap: not having a clear picture of what the directive actually does.
In the App Router, every component is a Server Component by default. Server Components run only on the server: they can read databases and secrets directly, they add zero bytes to the client bundle, and their output is streamed to the browser as a serialized UI description. Adding "use client" to a file marks a boundary: that component — and everything it imports — becomes client code, shipped to the browser with full interactivity (state, effects, event handlers). The directive is not a per-component switch; it is a line drawn across your import graph.
Rule of thumb: treat Client Components as exceptions, not defaults. Push the boundary as far down the tree as possible — a page can be 95% server-rendered with one small interactive island.
| Server Components | Client Components |
|---|---|
| Data fetching (DB, APIs, files) | useState / useEffect / useReducer |
| Secrets, tokens, backend SDKs | onClick, onChange, form interactivity |
| Static markup, lists, tables | Browser APIs (localStorage, geolocation) |
| Heavy formatting libraries | Real-time UI, animations, third-party widget SDKs |
The page does the data work; a small client island owns the interactivity. Notice that the server component passes plain data across the boundary — never functions or class instances.
import { db } from "@/lib/db";
import { OrderTable } from "@/components/order-table";
export default async function DashboardPage() {
const orders = await db.query.orders.findMany({
orderBy: (o, { desc }) => [desc(o.createdAt)],
limit: 100,
});
return (
<main>
<h1>Recent orders</h1>
<OrderTable orders={orders} />
</main>
);
}Server fetches, client filters — each side does what it is best at.
"use client";
import { useState } from "react";
type Order = { id: number; customer: string; total: number };
export function OrderTable({ orders }: { orders: Order[] }) {
const [filter, setFilter] = useState("");
const visible = orders.filter((o) =>
o.customer.toLowerCase().includes(filter.toLowerCase())
);
return (
<div>
<input
placeholder="Filter by customer..."
value={filter}
onChange={(e) => setFilter(e.target.value)}
/>
<table>
<tbody>
{visible.map((o) => (
<tr key={o.id}>
<td>{o.customer}</td>
<td>{o.total.toFixed(2)}</td>
</tr>
))}
</tbody>
</table>
</div>
);
}State and events live here — and nowhere else in the tree.
A Client Component cannot import a Server Component — but it can render one passed as children or any prop. The server renders that content first and hands the finished UI through the boundary. This is how you keep a client-side modal or accordion wrapper while its content stays server-only:
// components/collapsible.tsx
"use client";
import { useState } from "react";
export function Collapsible({ title, children }: {
title: string;
children: React.ReactNode;
}) {
const [open, setOpen] = useState(false);
return (
<section>
<button onClick={() => setOpen(!open)}>{title}</button>
{open && children}
</section>
);
}
// app/reports/page.tsx (Server Component)
import { Collapsible } from "@/components/collapsible";
import { HeavyReport } from "@/components/heavy-report"; // server-only
export default function ReportsPage() {
return (
<Collapsible title="Q4 revenue breakdown">
<HeavyReport /> {/* rendered on the server, passed through */}
</Collapsible>
);
}Composition beats importing: the boundary wraps content instead of replacing it.
Props crossing from server to client must be serializable. Strings, numbers, booleans, plain objects, arrays, Date, Map, Set and promises are fine. Functions, class instances and Symbols are not — the classic error "Functions cannot be passed directly to Client Components" means you tried to hand a callback across the line. The fix is a Server Action: an async function marked "use server" that the client can invoke like an RPC.
"use client" at the top of a layout or page file turns the entire subtree into client code. Move it down to the leaf that needs events.import "server-only" enforces this at build time).The payoff: teams that apply these patterns routinely cut client JS by 40–70% on content-heavy pages, which shows up directly in LCP and INP. Architecture is performance work.
Restructuring an existing App Router codebase around these boundaries is exactly the kind of work our team does day-to-day — see our services or get in touch for an architecture review.

Senior Developer
Francis Njenga is an experienced Lead Developer specializing in React, Next.js, and modern JavaScript frameworks, with a strong background in web development.