In an RSC app, modules are server code by default. 'use client' at the very top of a file (above imports; comments are fine; quotes, not backticks) marks that module and all its transitive dependencies as client code. Where server code imports such a module, the bundler cuts the graph: the server gets a client reference for each export, and the client bundle gets the module plus everything it imports.
What follows from that:
- It marks modules, not components.
caption.jsbelow has no directive but ships to the browser because a client module imports it. A module without a directive can run on both sides, depending on who imports it. - "Client" doesn't mean "only in the browser". Client Components are still server-rendered to HTML and hydrated. The RSC server just never runs them: it sends a reference in the payload.
- Only entry points need it. Inside the client graph the directive has no effect. Add it where server code imports something that needs the client: state, Effects, event handlers, browser APIs, or a third-party component that uses them and doesn't ship its own marker.
Direction matters. A Server Component can import and render a Client Component, passing serializable props. A client module can't import a Server Component: the import would make it client code. But a Client Component can render Server Component output when a Server Component passes it in as children or another JSX prop. The render tree can nest server inside client; the module graph can't.
So put the boundary low: mark the small interactive leaves and keep pages and data-loading parents as Server Components. Modules that must never reach the client can import the server-only package, which throws outside the react-server condition.