Provide comprehensive guidance for choosing between Server Components and Client Components in Next.js App Router, including cookie/header access, searchParams handling, pathname routing, and React's 'use' API for promise unwrapping.
Works with
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionnextjs-server-client-componentsExecute the skills CLI command in your project's root directory to begin installation:
Fetches nextjs-server-client-components from wsimmonds/claude-nextjs-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate nextjs-server-client-components. Access via /nextjs-server-client-components in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
82
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
82
stars
Provide comprehensive guidance for choosing between Server Components and Client Components in Next.js App Router, including cookie/header access, searchParams handling, pathname routing, and React's 'use' API for promise unwrapping.
any TypeCRITICAL RULE: This codebase has @typescript-eslint/no-explicit-any enabled. Using any will cause build failures.
❌ WRONG:
function handleSubmit(e: any) { ... }
const data: any[] = [];
✅ CORRECT:
function handleSubmit(e: React.FormEvent<HTMLFormElement>) { ... }
const data: string[] = [];
// Page props
function Page({ params }: { params: { slug: string } }) { ... }
function Page({ searchParams }: { searchParams: { [key: string]: string | string[] | undefined } }) { ... }
// Form events
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { ... }
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { ... }
// Server actions
async function myAction(formData: FormData) { ... }
Use this skill when:
All components in the App Router are Server Components by default. No directive needed.
// app/components/ProductList.tsx
// This is a Server Component (default)
export default async function ProductList() {
const products = await fetch('https://api.example.com/products');
const data = await products.json();
return (
<ul>
{data.map(product => (
<li key={product.id}>{product.name}</li>
))}
</ul>
);
}
When to use Server Components:
Benefits:
Add 'use client' directive at the top of a file to make it a Client Component.
// app/components/Counter.tsx
'use client';
import { useState } from 'react';
export default function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
}
When to use Client Components:
Requirements for Client Components:
'use client' directive at top of fileServer Components are the DEFAULT. DO NOT add 'use client' unless you specifically need client-side features.
✅ CORRECT - Server Component with Navigation:
// app/page.tsx - Server Component (NO 'use client' needed!)
import Link from 'next/link';
import { redirect } from 'next/navigation';
export default async function Page() {
// Server components can be async
const data = await fetchData();
if (!data) {
redirect('/login'); // Server-side redirect
}
return (
<div>
<Link href="/dashboard">Go to Dashboard</Link>
<p>{data.content}</p>
</div>
);
}
❌ WRONG - Adding 'use client' to Server Component:
// app/page.tsx
'use client'; // ❌ WRONG! Don't add this to server components!
export default async function Page() { // ❌ Will fail - async client components not allowed
const data = await fetchData();
return <div>{data.content}</div>;
}
Server Navigation Methods (NO 'use client' needed):
<Link> component from next/linkredirect() function from next/navigationClient Navigation Methods (REQUIRES 'use client'):
useRouter() hook from next/navigationusePathname() hookuseSearchParams() hook (also requires Suspense)Use next/headers to read cookies in Server Components:
// app/dashboard/page.tsx
import { cookies } from 'next/headers';
export default async function Dashboard() {
const cookieStore = await cookies();
const token = cookieStore.get('session-token');
if (!token) {
redirect('/login');
}
const user = await fetchUser(token.value);
return <div>Welcome, {user.name}</div>;
}
Important Notes:
cookies() must be awaited in Next.js 15+Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
laguagu/claude-code-nextjs-skills
anthropics/claude-code
mblode/agent-skills
github/awesome-copilot
leonxlnx/taste-skill
sickn33/antigravity-awesome-skills
I recommend nextjs-server-client-components for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
Registry listing for nextjs-server-client-components matched our evaluation — installs cleanly and behaves as described in the markdown.
nextjs-server-client-components fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
nextjs-server-client-components is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
nextjs-server-client-components is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
nextjs-server-client-components fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
nextjs-server-client-components reduced setup friction for our internal harness; good balance of opinion and flexibility.
Useful defaults in nextjs-server-client-components — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Registry listing for nextjs-server-client-components matched our evaluation — installs cleanly and behaves as described in the markdown.
I recommend nextjs-server-client-components for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
showing 1-10 of 37