/react-19:managing-server-vs-client-boundariesfrom react-19
Teaches when to use Server Components vs Client Components in React 19, including the 'use client' directive and boundary patterns. Use when architecting components, choosing component types, or working with Server Components.
Ships in react-19. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Role: Choose between Server and Client Components effectively and manage boundaries between them.
'use client'| Feature | Server Component | Client Component |
|---|---|---|
| Directive | None (default) | 'use client' |
| Hooks; Event handlers; Browser APIs | ❌ | ✅ |
| Async/await (top-level) | ✅ | ⚠️ Limited |
| Database/server APIs | ✅ Direct | ❌ Use Server Actions |
| Import Server Components | ✅ | ❌ Pass as children |
| Bundle impact | 📦 Zero | 📦 Sent to client |
| Bundle reduction | 20%-90% | — |
Key Decision: Needs interactivity/hooks/browser APIs → Client Component; static/server-only data → Server Component
Choose Client Component if: needs hooks, event handlers, browser APIs, or state management.
Choose Server Component if: purely presentational, fetches server data, accesses databases/server APIs.
Step 1: Add 'use client' at file top (Client Components only)
'use client';
import { useState } from 'react';
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
}
Step 2: Compose Server + Client
Server Components import Client Components; pass Server Components as children to avoid circular imports:
// Server Component: Can fetch data, import CC
import { Counter } from './Counter';
async function Page() {
const data = await db.getData();
return (
<div>
<h1>{data.title}</h1>
<Counter />
</div>
);
}
// ❌ WRONG: Client Component importing Server Component
('use client');
import ServerComponent from './ServerComponent'; // ERROR
// ✅ RIGHT: Pass Server Component as children
<ClientWrapper>
<ServerComponent />
</ClientWrapper>;
Interactivity at leaf nodes: Server Component fetches data, passes to Client Component for interaction
async function ProductPage({ id }) {
const product = await db.products.find(id);
return (
<>
<ProductDetails product={product} />
<AddToCartButton productId={id} />
</>
);
}
Server data in Client Component: Pass as props (serialize data)
async function ServerComponent() {
const data = await fetchData();
return <ClientComponent data={data} />;
}
Server logic from Client: Use Server Actions
async function ServerComponent() {
async function serverAction() {
'use server';
await db.update(...);
}
return <ClientForm action
={serverAction} />;
}
// Server Component
import { AddToCart } from './AddToCart';
import { Reviews } from './Reviews';
async function ProductPage({ productId }) {
const product = await db.products.find(productId);
const reviews = await db.reviews.findByProduct(productId);
return (
<main>
<img src={product.image} alt={product.name} />
<section>
<h1>{product.name}</h1>
<p>{product.description}</p>
<p>${product.price}</p>
<AddToCart productId={productId} />
</section>
<Reviews reviews={reviews} />
</main>
);
}
// Client Component
('use client');
import { useState } from 'react';
export function AddToCart({ productId }) {
const [adding, setAdding] = useState(false);
async function handleAdd() {
setAdding(true);
await fetch('/api/cart', {
method: 'POST',
body: JSON.stringify({ productId }),
});
setAdding(false);
}
return (
<button onClick={handleAdd} disabled={adding}>
{adding ? 'Adding...' : 'Add to Cart'}
</button>
);
}
// Server Component with real-time Client
async function Dashboard() {
const stats = await db.stats.getLatest();
return (
<>
<DashboardStats stats={stats} />
<LiveMetrics />
</>
);
}
// Client Component with WebSocket
('use client');
import { useEffect, useState } from 'react';
export function LiveMetrics() {
const [metrics, setMetrics] = useState(null);
useEffect(() => {
const ws = new WebSocket('/api/metrics');
ws.onmessage = (event) => setMetrics(JSON.parse(event.data));
return () => ws.close();
}, []);
return metrics ? <div>Active Users: {metrics.activeUsers}</div> : <div>Connecting...</div>;
}
// Server Component with Server Action
async function ContactPage() {
async function submitContact(formData) {
'use server';
await db.contacts.create({
email: formData.get('email'),
message: formData.get('message'),
});
}
return (
<form action={submitContact}>
<input name="email" type="email" />
<textarea name="message" />
<button type="submit">Send</button>
</form>
);
}
MUST: 'use client' at file top for Client Components; before any imports; serialize props (Server → Client); use Server Actions for server-side logic from Client
SHOULD: Keep most components as Server Components (smaller bundle); place 'use client' at leaf nodes (smallest boundary); use Server Components for data fetching; use Client Components only for interactivity
NEVER: Import Server Components into Client Components; use hooks in Server Components; access browser APIs in Server Components; pass non-serializable props (functions, classes, symbols); om
it 'use client' directive
'use client' at top; Server Components have no directive; no hooks/event handlers in Server Componentsresearch/react-19-comprehensive.md (lines 71-82)forms/skills/server-actions/SKILL.mdcomponent-composition/SKILL.mdWhat SKILL.md sets; muted values are Claude Code's defaults
26 skills in this plugin
/composing-componentsTeaches component composition patterns in React 19 including children prop, compound components, and render props. Use when designing component APIs, creating reusable components, or avoiding prop drilling./following-the-rules-of-hooksFix React Rules of Hooks violations - conditional calls, hooks in loops/callbacks/classes/implementing-code-splittingTeaches code splitting with lazy() and Suspense in React 19 for reducing initial bundle size. Use when implementing lazy loading, route-based splitting, or optimizing performance.Other plugins' skills for the same job
npx claudepluginhub djankies/claude-configs --plugin react-19