Most of the confusion around "use client" comes from one wrong mental model: that it marks a component as "client-only". It doesn't. It marks a boundary. Everything imported from that file, and everything it renders as children of its own module graph, ships to the browser.
What the directive actually does
When you put "use client" at the top of a file, you are saying: this module and everything it imports is part of the client bundle. Server Components can still render it, and can pass it serializable props, but the code inside is hydrated in the browser.
That means the cost is not the one component. It is the whole import tree under it.
The mistake I see most
A page needs one interactive piece, say a dropdown. Someone adds "use client" at the top of the page file because that is where the error appeared. Now the page, its data helpers, its formatting libraries and every child it imports are all client code.
The fix is to push the boundary down:
// app/products/page.tsx (Server Component, no directive)
import { getProducts } from "@/lib/products";
import { SortMenu } from "./sort-menu";
export default async function Page() {
const products = await getProducts();
return (
<>
<SortMenu />
<ProductList items={products} />
</>
);
}
// app/products/sort-menu.tsx
"use client";
import { useState } from "react";
export function SortMenu() {
const [open, setOpen] = useState(false);
return <button onClick={() => setOpen(!open)}>Sort</button>;
}
Only SortMenu and what it imports go to the browser. The data fetching stays on the server.
Children can cross the boundary
A client component can receive Server Components as children. The server renders them first, and the client component just places the result:
"use client";
export function Modal({ children }: { children: React.ReactNode }) {
const [open, setOpen] = useState(false);
return open ? <div role="dialog">{children}</div> : null;
}
This lets you keep a heavy, server-rendered body inside a small interactive wrapper.
A short checklist
- Put the directive on the smallest leaf that needs state, effects or browser APIs.
- Do not import server-only code (database clients, secrets) into a client file. Use
import "server-only"to make that a build error. - Props crossing the boundary must be serializable. No functions, no class instances.
- If a whole page feels like it needs to be client, check whether a wrapper plus
childrensolves it first.
Why it matters
Bundle size and hydration cost grow with the client import tree, not with the number of components you marked. Thinking in boundaries instead of "client components" keeps pages mostly server-rendered, and the interactive parts small.
Top comments (0)