Agent SkillsAgent Skills
jovermier

nextjs-server-components

@jovermier/nextjs-server-components
jovermier
2
0 forks
Updated 4/6/2026
View on GitHub

Next.js App Router Server Components, Client Components, layouts, data fetching, and Server Actions. Use when working with Next.js app directory, component boundaries, or data fetching patterns.

Installation

$npx agent-skills-cli install @jovermier/nextjs-server-components
Claude Code
Cursor
Copilot
Codex
Antigravity

Details

Pathplugins/cc-nextjs/skills/nextjs-server-components/SKILL.md
Branchmain
Scoped Name@jovermier/nextjs-server-components

Usage

After installing, this skill will be available to your AI coding assistant.

Verify installation:

npx agent-skills-cli list

Skill Instructions


name: nextjs-server-components description: Next.js App Router Server Components, Client Components, layouts, data fetching, and Server Actions. Use when working with Next.js app directory, component boundaries, or data fetching patterns.

Next.js Server Components

Expert guidance for using Next.js Server Components effectively.

Quick Reference

ConceptPatternWhen to Use
Server ComponentDefault (no "use client")Data fetching, heavy computation, no interactivity
Client ComponentAdd "use client"State, hooks, browser APIs, event handlers
Layoutapp/layout.tsxShared UI across routes
Templateapp/template.tsxShared UI that re-renders on navigation
Server Actionasync function in Server ComponentForm mutations, data updates
Parallel Routesfolder@(sidebar)Independent route segments

What Do You Need?

  1. Server vs Client - Choosing the right component type
  2. Data fetching - Async components, caching, revalidation
  3. Server Actions - Form handling, mutations
  4. Patterns - Composition, prop drilling prevention
  5. Streaming - Suspense boundaries, loading states

Specify a number or describe your Next.js component scenario.

Routing

ResponseReference to Read
1, "server", "client", "boundary"component-types.md
2, "data", "fetch", "cache", "revalidate"data-fetching.md
3, "action", "mutation", "form"server-actions.md
4, "pattern", "composition", "prop drilling"patterns.md
5, "suspense", "loading", "streaming"streaming.md

Essential Principles

Default to Server Components: Only add "use client" when you genuinely need client-side features. This is the single most important Next.js best practice.

Server Components for: Data fetching, database queries, API calls, heavy computation, keeping sensitive tokens safe.

Client Components for: State (useState), effects (useEffect), browser APIs, event handlers, React hooks.

Push Client Components down: Move "use client" as deep in the tree as possible. Keep the root Server Component.

Common Issues

IssueSeverityFix
Client Component that should be ServerHighRemove "use client", make async
Fetching in useEffectHighUse Server Component or Server Action
"use client" at rootMediumPush down to leaf components
Not using async for data fetchingLowMake Server Component async
Prop drilling through ServerLowPass to Client child, don't bridge

Code Patterns

Server Component (Default)

// Good: Async Server Component
export default async function UserProfile({ userId }: { userId: string }) {
  const user = await fetchUser(userId)
  return <div>{user.name}</div>
}

Client Component (When Needed)

"use client"

import { useState } from 'react'

export function InteractiveButton() {
  const [count, setCount] = useState(0)
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>
}

Server Action

// Server Action in Server Component
async function createTodo(formData: FormData) {
  'use server'
  const title = formData.get('title') as string
  await db.todos.create({ title })
}

export default function Page() {
  return <form action={createTodo}>...</form>
}

Reference Index

FileTopics
component-types.mdServer vs Client, boundary placement
data-fetching.mdAsync components, fetch caching, revalidation
server-actions.mdForm actions, mutations, revalidation
patterns.mdComposition, prop drilling prevention
streaming.mdSuspense, loading.tsx, progressive rendering

Success Criteria

Components are correct when:

  • Default to Server (no "use client" unless needed)
  • "use client" only for interactivity, browser APIs, hooks
  • Data fetching in Server Components, not useEffect
  • Server Actions for mutations, not API routes
  • Client boundaries pushed down as far as possible
nextjs-server-components by jovermier | Agent Skills