Build Next.js 15 applications using App Router, Server Components, Client Components, Server Actions, and streaming. Apply when creating pages, handling data fetching, implementing routes, or optimizing performance.
Build Next.js 15 applications using App Router, Server Components, Client Components, Server Actions, and streaming. Apply when creating pages, handling data fetching, implementing routes, or optimizing performance.
allowed-tools
Read, Write, Edit, Bash
version
1.1.0
compatibility
Claude Opus 4.5, Claude Code v2.x
updated
"2026-01-24T00:00:00.000Z"
Next.js App Router & Server Components
Systematic Next.js 15 development with App Router, Server Components, and performance optimization.
Overview
This Skill enforces:
Server Components by default (use client only when needed)
Proper data fetching patterns
File-based routing with App Router
Server Actions for mutations
Streaming and Suspense boundaries
Performance optimization
Route handlers and middleware
Apply when building Next.js pages, implementing routes, or optimizing performance.
Server vs Client Components
Default: Server Components (no directive needed)
When needed: Client Components (add 'use client')
Decision Tree
Does component need browser APIs?
├─ YES → Client Component ('use client')
└─ NO → Server Component (default)
Does component need event handlers?
├─ YES → Client Component
└─ NO → Server Component
Does component need state or effects?
├─ YES → Client Component
└─ NO → Server Component
Does component fetch data?
├─ YES → Server Component (preferred)
└─ NO → Check other criteria
Server Components (Default)
Benefits
Runs on server only
Zero JavaScript sent to browser
Direct database access
Access to secrets
Better SEO
Faster initial load
Example
// app/users/page.tsx// No 'use client' = Server Componentimport { db } from'@/lib/db';
exportdefaultasyncfunctionUsersPage() {
// Direct database query (server-only)const users = await db.user.findMany();
return (
<div><h1>Users</h1><ul>
{users.map(user => (
<likey={user.id}>{user.name}</li>
))}
</ul></div>
);
}
Data Fetching in Server Components
// ✅ GOOD: Async component with awaitexportdefaultasyncfunctionPage() {
const data = awaitfetch('https://api.example.com/data', {
next: { revalidate: 3600 } // Cache for 1 hour
});
const result = await data.json();
return<div>{result.title}</div>;
}
// ✅ GOOD: Parallel data fetchingexportdefaultasyncfunctionPage() {
const [users, posts] = awaitPromise.all([
fetch('https://api.example.com/users').then(r => r.json()),
fetch('https://api.example.com/posts').then(r => r.json())
]);
return (
<div><Usersdata={users} /><Postsdata={posts} /></div>
);
}
// ❌ BAD: useEffect in Server ComponentexportdefaultfunctionPage() {
useEffect(() => {
// This doesn't work in Server Components!fetchData();
}, []);
}
Client Components
When to Use
Add 'use client' when you need:
Event handlers (onClick, onChange, etc.)
State (useState, useReducer)
Effects (useEffect, useLayoutEffect)
Browser APIs (localStorage, window, navigator)
Custom hooks that use above
Interactive UI (modals, dropdowns, forms with validation)
Last Updated: January 24, 2026
Compatibility: Claude Opus 4.5, Claude Code v2.x
Status: Production Ready
January 2026 Update: This skill is compatible with Claude Opus 4.5 and Claude Code v2.x. For complex tasks, use the effort: high parameter for thorough analysis.