nextjs-server-client-components

Determine Server versus Client Component usage in Next.js App Router.

Updated Dec 17, 2025
One-click install
npx skills add https://github.com/mcclowes/vague-playground --skill nextjs-server-client-components
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nextjs-server-client-components
Source: https://github.com/mcclowes/vague-playground/tree/main/.claude/skills/nextjs-server-client-components
Command: npx skills add https://github.com/mcclowes/vague-playground --skill nextjs-server-client-components

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clarifies when to use Server Components vs Client Components in Next.js App Router, covering useSearchParams, Suspense, navigation, cookies/headers access, and the 'use client' directive.

Core Features & Use Cases

  • Default Server Components with async data fetching
  • Client Components via 'use client' when necessary
  • Guidance to avoid mixing server/client APIs

Quick Start

Use Server Components by default. If you need interactivity, add 'use client' and migrate only the necessary parts; example: server component fetches data, client component handles events.

Frequently Asked Questions about nextjs-server-client-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use Server Components vs Client Components in Next.js?▼

Server Components are the default in Next.js App Router and handle data fetching, cookies, headers, and server-only APIs. Use Client Components only when you need interactivity; add 'use client' at the top and migrate only the necessary component, keeping data fetching on the server side.

How do I access searchParams and routing data in Next.js App Router?▼

Use Server Components to access searchParams, pathname, and routing information directly. Client Components cannot access these; use 'use client' only for interactive features, and pass routing data from the server parent as props.

What's the correct way to handle the 'use client' directive in Next.js?▼

Place 'use client' at the top of a component file only when you need browser APIs or event handlers. Server-only APIs like cookies and headers will throw errors if called in Client Components; keep them in Server Components and pass results as props.

Can I use Suspense and async data fetching with Server Components in Next.js?▼

Yes. Server Components support async/await for data fetching and Suspense for unwrapping results. This approach keeps data fetching on the server, reducing client-side JavaScript and improving performance compared to Client Components with useEffect.

How do I handle navigation in Next.js when using Server and Client Components?▼

Use server-side navigation with Link and redirect in Server Components by default. Client-side routing requires 'use client', but server navigation is preferred for better performance and SEO in Next.js App Router.

Why do I get errors when accessing cookies or headers in Client Components?▼

Cookies and headers are server-only APIs; Client Components cannot access them. Move cookie and header logic to a Server Component parent, fetch the data there, and pass the results as props to your Client Component for rendering or interactivity.