react-server-components
Skill0 starsChanged 5 months agoMITView on GitHub
Build server-first React with Next.js 16 App Router — Server/Client component boundaries, Cache Components, streaming SSR, Server Actions, and React 19 patterns. Use when working in app/, deciding server vs client, or debugging hydration and serialization issues.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- codecharmhq/claude-code-skillstheir own version, first seen May 17, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- codecharmhq/claude-code-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- context-engineeringSkill
- multi-agent-patternsSkill
- prompt-injection-defenseSkill
- rag-retrievalSkill
- adr-writerSkill
- ci-cdSkill
- playwright-e2eSkill
- structural-searchSkill
- shadcn-uiSkill
- tailwind-v4Skill
- zustand-stateSkill
- accessibilitySkill
- api-designSkill
- database-patternsSkill
- debuggingSkill
- security-patternsSkill
- typescript-patternsSkill
- proposal-writerSkill
- task-prioritizationSkill
- sitecore-xmcloudSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 170
Keep Client Components at the edges (leaves) of the component tree
- Distinctive: line 171
Use Server Components by default
- Very specific: line 177
Use parallel fetching (Promise.all) for independent data
- Very specific: line 179
Use generateStaticParams for static routes
- Distinctive: line 182
Use Suspense boundaries for streaming
- Distinctive: line 185
Use route segment config to control rendering mode
- Distinctive: line 222
After mastering React Server Components:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Server Components Framework
Overview
React Server Components (RSC) enable server-first rendering with client-side interactivity. This skill covers Next.js 16.2 LTS App Router patterns, Server Components, Server Actions, and streaming.
Next.js 16.2.6 / React 19.2.6 (security release, May 2026) — Turbopack is the default bundler (no
--turboflag needed), Server Fast Refresh is on by default, and the newcacheComponentsconfig flag replaces the legacyexperimental_pprescape hatch. For AI-agent debugging Next.js ships Next DevTools MCP — wirenpx -y next-devtools-mcp@latestinto.mcp.json(it connects via the dev server's/_next/mcpendpoint) to inspect render trees and cache boundaries mid-session.
When to use this skill:
- Building Next.js 16+ applications with the App Router
- Designing component boundaries (Server vs Client Components)
- Implementing data fetching with caching and revalidation
- Creating mutations with Server Actions
- Optimizing performance with streaming and Suspense
Quick Reference
Server vs Client Components
| Feature | Server Component | Client Component |
| Directive | None (default) | 'use client' |
| Async/await | Yes | No |
| Hooks | No | Yes |
| Browser APIs | No | Yes |
| Database access | Yes | No |
| Client JS bundle | Zero | Ships to client |
Key Rule: Server Components can render Client Components, but Client Components cannot directly import Server Components (use children prop instead).
Data Fetching Quick Reference
Next.js 16 Cache Components (Recommended):
import { cacheLife, cacheTag } from 'next/cache'
// Default — shared across all users (public CDN-cached)
async function CachedProducts() {
'use cache'
cacheLife('hours')
cacheTag('products')
return await db.product.findMany()
}
// Remote variant (16.2+) — always served from the edge/CDN, never rendered
// inline on the origin. Best for static product listings, marketing content.
async function MarketingHero() {
'use cache: remote'
cacheLife('days')
return <Hero />
}
// Private variant (16.2+) — cached per-user session. Never shared across
// users. Use for personalized dashboards with expensive computation.
async function UserDashboard({ userId }: { userId: string }) {
'use cache: private'
cacheLife('minutes')
cacheTag(`user:${userId}`)
return await loadDashboard(userId)
}
// Invalidate cache — v16 requires a cacheLife profile as the 2nd arg
import { revalidateTag } from 'next/cache'
revalidateTag('products', 'max') // or updateTag('products') for read-your-writesEnable via next.config.ts:
import type { NextConfig } from 'next'
const config: NextConfig = {
cacheComponents: true, // 16.2+ — replaces experimental_ppr flag
}
export default configLegacy Fetch Options (Next.js 15):
// Static (cached indefinitely)
await fetch(url, { cache: 'force-cache' })
// Revalidate every 60 seconds
await fetch(url, { next: { revalidate: 60 } })
// Always fresh
await fetch(url, { cache: 'no-store' })
// Tag-based revalidation
await fetch(url, { next: { tags: ['posts'] } })Server Actions Quick Reference
'use server'
export async function createPost(formData: FormData) {
const title = formData.get('title') as string
const post = await db.post.create({ data: { title } })
revalidatePath('/posts')
redirect("/posts/" + post.id)
}Async Params/SearchParams (Next.js 16)
Route parameters and search parameters are now Promises that must be awaited:
// app/posts/[slug]/page.tsx
export default async function PostPage({
params,
searchParams,
}: {
params: Promise<{ slug: string }>
searchParams: Promise<{ page?: string }>
}) {
const { slug } = await params
const { page } = await searchParams
return <Post slug={slug} page={page} />
}Note: Also applies to layout.tsx, generateMetadata(), and route handlers. Load: Read("${CLAUDE_SKILL_DIR}/references/nextjs-16-upgrade.md") for complete migration guide.
Dev Server (Next.js 16.2 LTS)
- Turbopack default —
next devandnext buildrun Turbopack without any flag. Pass--webpackonly when forced (legacy plugin). - Server Fast Refresh — Server Components hot-reload on save without losing client state. No extra config; it's on by default in 16.2.
- Next DevTools MCP — register
npx -y next-devtools-mcp@latestin.mcp.json; it attaches to the running dev server over the/_next/mcpendpoint and exposes RSC payloads and cache boundaries to an MCP client. Designed for AI agents that need to inspect render trees mid-session without screenshotting. (There is nonext-browserbinary.)
References
Load on demand with Read("${CLAUDE_SKILL_DIR}/references/<file>"):
| File | Content |
server-components.md | Async server components, data fetching patterns, route segment config, generateStaticParams, error handling |
client-components.md | 'use client' directive, React 19 patterns, interactivity, hydration, composition via children |
streaming-patterns.md | Suspense boundaries, loading.tsx, parallel streaming, PPR, skeleton best practices |
react-19-patterns.md | Function declarations, ref as prop, useActionState, useFormStatus, useOptimistic, Activity, useEffectEvent |
server-actions.md | Progressive enhancement, useActionState forms, Zod validation, optimistic updates |
routing-patterns.md | Parallel routes, intercepting routes, route groups, dynamic and catch-all routes |
migration-guide.md | Pages Router to App Router migration, getServerSideProps/getStaticProps replacement |
cache-components.md | "use cache" directive (replaces experimental_ppr), cacheLife, cacheTag, revalidateTag, PPR integration |
nextjs-16-upgrade.md | Node.js 20.9+, breaking changes (async params, cookies, headers), proxy.ts migration, Turbopack, new caching APIs |
tanstack-router-patterns.md | React 19 features without Next.js, route-based data fetching, client-rendered app patterns |
capability-details.md | Keyword and problem-mapping metadata for all 12 RSC capabilities |
Best Practices Summary
Component Boundaries
- Keep Client Components at the edges (leaves) of the component tree
- Use Server Components by default
- Extract minimal interactive parts to Client Components
- Pass Server Components as
childrento Client Components
Data Fetching
- Fetch data in Server Components close to where it's used
- Use parallel fetching (
Promise.all) for independent data - Set appropriate cache and revalidate options
- Use
generateStaticParamsfor static routes
Performance
- Use Suspense boundaries for streaming
- Implement loading.tsx for instant loading states
- Enable PPR for static/dynamic mix
- Use route segment config to control rendering mode
Templates
scripts/ServerComponent.tsx- Basic async Server Component with data fetchingscripts/ClientComponent.tsx- Interactive Client Component with hooksscripts/ServerAction.tsx- Server Action with validation and revalidation
Troubleshooting
| Error | Fix |
| "You're importing a component that needs useState" | Add 'use client' directive |
| "async/await is not valid in non-async Server Components" | Add async to function declaration |
| "Cannot use Server Component inside Client Component" | Pass Server Component as children prop |
| "Hydration mismatch" | Use 'use client' for Date.now(), Math.random(), browser APIs |
| "params is not defined" or params returning Promise | Add await before params (Next.js 16 breaking change) |
| "experimental_ppr is not a valid export" | Use Cache Components with "use cache" directive instead |
| "cookies/headers is not a function" | Add await before cookies() or headers() (Next.js 16) |
Resources
Related Skills
After mastering React Server Components:
- Streaming API Patterns - Real-time data patterns
- Type Safety & Validation - tRPC integration
- Edge Computing Patterns - Global deployment
- Performance Optimization - Core Web Vitals
Capability Details
Keyword and problem-mapping metadata for each RSC capability (react-19-patterns, use-hook-suspense, optimistic-updates-async, rsc-patterns, server-actions, data-fetching, streaming-ssr, caching, cache-components, tanstack-router-patterns, async-params, nextjs-16-upgrade).
Load full capability details: Read("${CLAUDE_SKILL_DIR}/references/capability-details.md")
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

