React Server Components (Part 2): Design the Server and Client Boundary
Learn how to structure real RSC applications: use-client boundaries, composition, providers, third-party components, serializable props and keeping client bundles small.

The most important RSC architecture decision is not whether your application “uses Server Components.” It is where the client boundary begins.
Put that boundary too high and a large dependency tree becomes browser code. Put it too low and you can make ordinary interactive UI awkward to build. The useful target is neither “all server” nor “all client.” It is a tree in which server-only work stays server-side and browser capabilities begin exactly where they are needed.
In Next.js App Router, pages and layouts are Server Components by default. A file marked 'use client' creates an entry point into the client module graph, and its imports become part of that graph. That makes boundary placement a bundle-design decision, not just syntax.
Start with a server page, then add interaction deliberately
Imagine a product page with a large amount of static/product data and one interactive purchase panel.
The weak approach is to make the page client-side because one button needs state:
'use client'
export default function ProductPage() {
// everything beneath here is now in the client graph
}
A better split is:
// app/products/[id]/page.tsx — Server Component
import { PurchasePanel } from './purchase-panel'
import { getProduct } from '@/lib/products'
export default async function ProductPage({ params }) {
const { id } = await params
const product = await getProduct(id)
return (
<main>
<h1>{product.name}</h1>
<ProductDescription html={product.description} />
<DeliveryInformation product={product} />
<PurchasePanel productId={product.id} price={product.price} />
</main>
)
}
// purchase-panel.tsx — Client Component
'use client'
import { useState } from 'react'
export function PurchasePanel({ productId, price }) {
const [quantity, setQuantity] = useState(1)
return (
<section>
<Quantity value={quantity} onChange={setQuantity} />
<button>Add {quantity} to basket — £{price * quantity}</button>
</section>
)
}
The product query, description and delivery rendering do not need a browser runtime. The quantity interaction does.
That is the basic RSC composition pattern.
'use client' pulls imports into the client graph
This is where seemingly innocent architecture decisions become expensive.
Suppose app-shell.tsx imports navigation, analytics helpers, formatters, a large icon package and several feature modules. Marking that shell 'use client' can make all of those transitive dependencies candidates for the client bundle.
That does not mean every byte is always emitted unchanged — bundlers still optimise — but you have moved the architectural boundary and given the browser responsibility for a much larger graph.
Prefer a server shell containing small client leaves:
RootLayout Server
├── Header Server
│ ├── Logo Server
│ └── AccountMenu Client
├── Main Server
│ └── route content Server/Client as needed
└── CookiePreferencesLauncher Client
A single dropdown does not justify making the whole layout client-side.
Server Components can compose Client Components
A Server Component can import and render a Client Component normally:
import { Expandable } from './expandable'
export default async function FAQ() {
const questions = await getQuestions()
return questions.map(question => (
<Expandable key={question.id} title={question.question}>
<p>{question.answer}</p>
</Expandable>
))
}
The interactive shell can remain tiny while the content is prepared server-side.
This pattern is especially useful for accordions, dialogs, tabs, carousels and other UI primitives where the interaction mechanism needs JavaScript but the content does not.
Pass Server Components as children rather than importing them into client code
A subtle but useful composition technique is to let a Server Component create the tree and pass server-rendered content into a Client Component slot.
// Server Component
export default function Page() {
return (
<InteractiveDrawer>
<ServerRenderedAccountDetails />
</InteractiveDrawer>
)
}
'use client'
export function InteractiveDrawer({ children }) {
const [open, setOpen] = useState(false)
return (
<>
<button onClick={() => setOpen(true)}>Account</button>
{open && <aside>{children}</aside>}
</>
)
}
The drawer owns browser state. The parent can still supply server-produced content.
The mistake would be trying to make the client module directly own server-only data access.
Providers belong as deep as practical
React context is a client-side capability in this architecture. A context provider therefore needs to be a Client Component.
That sometimes leads teams to do this:
<html>
<GlobalClientProvider>
<body>{children}</body>
</GlobalClientProvider>
</html>
It may work, but do not automatically wrap the entire document in client infrastructure merely because one feature needs context.
Keep providers as deep as their responsibility allows:
<body>
<Header />
<main>{children}</main>
<BasketProvider>
<BasketDrawer />
</BasketProvider>
</body>
This preserves more of the surrounding tree for server optimisation and makes dependencies easier to reason about.
There are legitimate application-wide providers — theme, authentication UI state or a global query client may be examples — but “global” should be a requirement, not the default.
Third-party components can force a client boundary
Not every library has been designed with RSC in mind.
A package may call hooks, touch browser globals or require context internally. If it does not expose an appropriate 'use client' boundary itself, wrap it in one:
// carousel.client.tsx
'use client'
export { Carousel } from 'browser-carousel-package'
Server code can then import your wrapper without turning unrelated application modules into client modules.
This also gives you one place to replace the library later.
Before adding a dependency to a Server Component, ask whether it is genuinely server-compatible. Packages that execute browser-only code at module import time are particularly troublesome.
Do not send giant objects across the boundary
A Client Component should receive the data required for its interaction, not whatever object happened to be available on the server.
Avoid:
<Editor user={fullUserRecord} account={fullAccountGraph} />
Prefer a purpose-built model:
<Editor
user={{ id: user.id, displayName: user.displayName }}
permissions={{ canPublish: permissions.canPublish }}
/>
This has several advantages: less serialized data, a clearer API, reduced accidental disclosure and less coupling between your database/domain model and browser UI.
The RSC boundary is a good place to practise data minimisation.
Client Components should not refetch data the server already has without a reason
A common migration anti-pattern looks like this:
// Server page fetches product
const product = await getProduct(id)
// Client child mounts and fetches the same product again
useEffect(() => fetch(`/api/products/${id}`), [id])
Sometimes the second request is justified because the data must remain live or independently refreshable. Often it is accidental duplication left over from an SPA architecture.
If the client only needs a small initial value, pass it across the boundary. If it needs ongoing synchronization, design that behaviour deliberately.
Keep interactivity local
A good boundary often surrounds a behaviour rather than a page.
Examples:
SearchResults Server
└── SortControls Client
Article Server
└── ShareMenu Client
Dashboard Server
├── KPI cards Server
├── Activity table Server
└── DateRangePicker Client
This gives the browser JavaScript where it adds value without making every display component hydrate merely because it sits near an interactive feature.
When a larger Client Component is appropriate
Do not over-fragment an inherently interactive feature just to achieve a theoretical minimum bundle.
A spreadsheet-like editor with keyboard shortcuts, selection state, drag-and-drop, optimistic updates and undo history is probably one coherent client application region. Splitting every cell into an artificial server/client puzzle can make the system worse.
Boundary design should optimise the whole system: bundle size, maintainability, network behaviour, state ownership and developer comprehension.
Avoid accidental browser/server duplication
Some utilities can run in either environment. That does not mean they should.
Suppose a 200 KB syntax-highlighting library is imported by both a Server Component and a client editor. You may now pay for versions of that dependency in both execution environments.
Inspect production bundles rather than assuming RSC automatically eliminates heavy JavaScript. Look for dependencies crossing client entry points unexpectedly.
A useful review question is:
If I delete this
'use client'directive, which exact capability stops working?
If nobody can answer, the boundary may be too high.
Check the result, not just the component tree
Once an RSC application is deployed, inspect what users actually receive: scripts, caching, headers, performance and page behaviour.
Boundary checklist for code review
Before approving a new Client Component boundary, check that it needs state, effects, events, context, browser APIs or a client-only dependency. Check whether the boundary can move lower without making the feature incoherent, whether server-only dependencies are accidentally imported below it, and whether props contain only the data the browser needs.
Also look for duplicated fetching, giant providers and client wrappers around entire pages for one small interaction.
The composition rule that scales
The most maintainable RSC applications tend to follow a simple rule:
Fetch and compose on the server by default; cross into the client where browser capability begins; keep that boundary as local as the feature allows.
That rule is not absolute, but it is a much better default than starting every route as a client application and trying to claw server behaviour back later.
In Part 3 we will deal with the next problem this architecture exposes: data fetching. We will cover parallel reads, waterfalls, request memoization, framework caching, revalidation and why “fetch in the component that needs it” can be either elegant or painfully slow depending on how you structure the work.
