install
source · Clone the upstream repo
git clone https://github.com/Intense-Visions/harness-engineering
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Intense-Visions/harness-engineering "$T" && mkdir -p ~/.claude/skills && cp -r "$T/agents/skills/claude-code/react-server-components" ~/.claude/skills/intense-visions-harness-engineering-react-server-components && rm -rf "$T"
manifest:
agents/skills/claude-code/react-server-components/SKILL.mdsource content
React Server Components
Run components on the server to eliminate client JavaScript and enable direct data access
When to Use
- Components that fetch data and render it without client-side interactivity
- Components that import large libraries (markdown parsers, date formatters) only needed for rendering
- You need direct database or filesystem access without an API layer
- Using Next.js App Router (RSC is the default) or another RSC-compatible framework
Instructions
- Server Components are the default in Next.js App Router. Do not add
unless needed.'use client' - Server Components can:
directly:async/awaitconst data = await db.query(...)- Import server-only libraries without impacting bundle size
- Read environment variables and secrets directly
- Add
directive at the top of a file when the component needs:'use client'
,useState
, or any hooksuseEffect- Browser APIs (
,window
)document - Event handlers (
,onClick
)onChange
- Composition rule: Server Components can render Client Components, but Client Components cannot render Server Components (only pass them as
props).children - Pass data from Server to Client Components as serializable props (no functions, classes, or non-serializable objects).
// Server Component (no 'use client') async function ProductPage({ id }: { id: string }) { const product = await db.products.findById(id); // direct DB access return ( <div> <h1>{product.name}</h1> <AddToCartButton productId={id} /> {/* Client Component */} </div> ); } // Client Component 'use client'; function AddToCartButton({ productId }: { productId: string }) { return <button onClick={() => addToCart(productId)}>Add to Cart</button>; }
Details
RSC introduces a server/client component split at the file level. The framework serializes server-rendered output as a JSON-like payload (RSC payload) and sends it to the client for React to reconcile.
What RSC eliminates:
- API routes for data fetching in many cases (direct DB access in server components)
- Client-side waterfall requests (async server components fetch in parallel)
- Bundle cost for render-only dependencies (they never reach the browser)
Common mistakes:
- Adding
to every file "to be safe" — this negates RSC benefits'use client' - Trying to pass functions as props from server to client components — functions are not serializable
- Using
for data fetching in client components when a server component would workuseEffect
Framework support (2024): Next.js App Router is the primary production implementation. Remix, Waku, and other frameworks have RSC support in various stages.
Source
https://patterns.dev/react/react-server-components
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.