Agent-skills-standard nextjs-server-components
Build async React Server Components and place 'use client' boundaries at leaf nodes for interactivity in Next.js App Router. Use when deciding RSC vs Client Component, composing server data into client wrappers, or fixing hydration errors. (triggers: app/**/*.tsx, src/app/**/*.tsx, app/**/*.jsx, src/app/**/*.jsx, use client, Server Component, Client Component, hydration)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/nextjs/nextjs-server-components" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-nextjs-server-components && rm -rf "$T"
manifest:
skills/nextjs/nextjs-server-components/SKILL.mdsource content
Server & Client Components
Priority: P0 (CRITICAL)
[!WARNING] If project uses
directory instead of App Router, ignore this skill entirely.pages/
App Router uses React Server Components (RSC) by default.
Workflow: Add Server/Client Component Split
- Default to RSC — Async Server Components for data fetching.
- Push
to leaves — Interactive leaf nodes only (Button, Form, Chart). Keep layouts/pages as Server Components to maximise RSC benefits.'use client' - Compose via children — Pass Server Components as
to Client Components.children - Serialize props — Server-to-Client props must be serializable (no functions, Dates, or Classes).
- Guard secrets — Import
in modules with sensitive logic.server-only
Composition Pattern Example
Implementation Guidelines
- Async RSCs: Fetch directly in async Server Components —
queries,await db.
for route segments.await params - Data Fetching:
withfetch
orcache: 'no-store'
opts out of static rendering.revalidate: 0 - Streaming: Wrap slow async components in
. Use<Suspense>
for route-level skeletons.loading.tsx - Hydration: Server sends HTML + RSC payload; client hydrates only Client Components. Server Components: zero JS in client bundle.
- Server-in-Client: Cannot import Server Component into Client Component.
- Fix: Pass as
prop. See Composition Example.children
Anti-Patterns
- No secrets in Client Components: Use
package to prevent accidental bundling.server-only - No full DB objects passed to client: Minimize serialized props; pass IDs when possible.
- No
/useState
in Server Components: These Client Component-only hooks.useEffect - No
at tree root: Push boundary to leaf components.'use client'