RSC module graph
What you need to know
React Server Components (RSC) establish a server/client module graph. A module graph is the set of imports followed from an entry point. In Next.js App Router, a client entry marks a boundary: dependencies reachable from it become part of the client-side graph when required.
By the end, you can: distinguish server and client imports; explain client bundle implications.
Keep the interactive wrapper small
// app/Reveal.tsx'use client';import {useState,type ReactNode} from 'react';export default function Reveal({children}:{children:ReactNode}){ const [open,setOpen]=useState(false); return <section><button aria-expanded={open} onClick={()=>setOpen(!open)}> {open?'Hide':'Show'} notes</button>{open && children}</section>;}Expected behavior: The browser toggles visibility of a child already supplied by its parent; hiding it is not access control.
How it works
The server graph can read local data and render components without delivering their implementation as ordinary browser component JavaScript. A client entry is needed for browser state, event handlers and other client-only features. The directive is about the module import boundary, not the appearance of the component tree. A shared formatting module without a directive can be evaluated on both sides if imported by both graphs; keep environment-specific dependencies out of that shared module. A Server Component can import and render a Client Component. It can also pass already composed server content as children to a Client Component, letting the client control visibility without importing the server implementation. A direct import of a server-only data module into a client entry is inappropriate; import 'server-only' makes the intended environment explicit and Next.js reports invalid imports during the build. Do not use the directive as a substitute for authorization or secret filtering. Even a Client Component can participate in initial HTML generation; browser-only APIs such as localStorage should not be read unconditionally during render. The staged example uses a small button as the interactive island and keeps the article text in a server module.
Compose server-rendered children
// app/page.tsx — companion to Reveal.tsximport Reveal from './Reveal';import 'server-only';function PublicNote(){return <p>Bring a library card.</p>;}export default function Page(){ return <main><h1>Reading room</h1><Reveal><PublicNote/></Reveal></main>;}Expected behavior: The server prepares the public note and supplies it to the wrapper. The client entry does not import PublicNote. Actual bundle behavior needs a framework build.
Common mistake
Putting use client on the root layout to make one toggle work expands the client import graph unnecessarily. Extract the interactive leaf; server-rendered children can still be passed into it. Never use conditional visibility to protect sensitive content.
Practice and verification
Draw import arrows for Page -> Reveal and Page -> PublicNote. Label the client entry and which modules must remain server-only. Add a staged negative build case importing a server-only module from a client entry; record the actual diagnostic only after a reviewed build.
Scope: App Router, proposed Next.js 16.x and React 19, Cache Components disabled. Framework snippets are staged, not executed; local policy, SQLite and HTTP transport evidence is separate. Exact patched dependencies and platform contracts are pending.
Further reading: Components · Client · React Client · Security Data