nextjs-expert
/nextjs-expert
Expert Next.js App Router: Server vs Client Components, data fetching, caching, server actions, and rendering strategy. Trigger keywords: Next.js, App Router, Server Components, RSC, use client, use server, server actions, route handler, generateStaticParams, revalidate, revalidatePath, middleware, streaming, Vercel, hydration. Use for routing, data/caching strategy, mutations, or rendering decisions in Next.js.
- Author
- miaoge-ge ↗
- Repository
- coding-agent-skills ↗
- Licence
- MIT
- Last repository change
- 31.05.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 1
No signals detected. Repository changed on 31.05.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Expert Next.js App Router: Server vs Client Components, data fetching, caching, server actions, and rendering strategy. Trigger keywords: Next.js, App Router, Server Components, RSC, use client, use server, server actions, route handler, generateStaticParams, revalidate, revalidatePath, middleware, streaming, Vercel, hydration. Use for routing, data/caching strategy, mutations, or rendering decisions in Next.js.
Original author description
Expert Next.js App Router: Server vs Client Components, data fetching, caching, server actions, and rendering strategy. Trigger keywords: Next.js, App Router, Server Components, RSC, use client, use server, server actions, route handler, generateStaticParams, revalidate, revalidatePath, middleware, streaming, Vercel, hydration. Use for routing, data/caching strategy, mutations, or rendering decisions in Next.js.
How it works
- When to Use
- When NOT to Use
- Core Principles
- Decision Guide
- Common Mistakes
- Examples
- See Also
SKILL.md preview
---
name: nextjs-expert
description: "Expert Next.js App Router: Server vs Client Components, data fetching, caching, server actions, and rendering strategy. Trigger keywords: Next.js, App Router, Server Components, RSC, use client, use server, server actions, route handler, generateStaticParams, revalidate, revalidatePath, middleware, streaming, Vercel, hydration. Use for routing, data/caching strategy, mutations, or rendering decisions in Next.js."
---
# Next.js Expert
> Server Components are the default; `"use client"` is a deliberate, leaf-level choice. Fetch on the server, cache explicitly, and keep secrets off the client.
## When to Use
- Building an App Router app: routing, layouts, `loading`/`error` UI, route groups.
- Deciding Server vs Client Components and rendering mode (static / dynamic / streaming / PPR).
- Data fetching, server actions/mutations, route handlers, and `revalidate*`.
- Debugging caching, hydration mismatches, or middleware.
## When NOT to Use
- Generic React hooks/component patterns → `react-expert`.
- Pure styling → `tailwind-expert`.
- A standalone (non-Next) API/server → `nodejs-backend-expert`.
## Core Principles
### 1. The server/client boundary is the whole game
- Everything is a **Server Component** unless it has `"use client"`. Add the directive only for state, effects, event handlers, or browser APIs — and keep it at the **leaves**.
- `"use client"` makes a component and its imported tree part of the client bundle. Pass server-fetched data down as props instead of pulling data into client components.
- **Never** import DB clients, secrets, or server-only SDKs into a client component. Guard with `import "server-only"`.
### 2. Fetch on the server, control caching explicitly
- `async`/`await` directly in Server Components; co-locate the fetch with the component that needs it (React dedups identical requests in a render).
- Caching is **opt-in and explicit** (especially Next 15, where fetches are uncached by default): `fetch(url, { cache: "force-cache" })`, `{ next: { revalidate: N } }` for ISR, or `{ cache: "no-store" }` for always-fresh.
- Tag data (`next: { tags: [...] }`) and invalidate precisely with `revalidateTag`/`revalidatePath` after writes.
### 3. Mutations via server actions
- `"use server"` functions for forms/mutations. **Validate and authorize on the server** — actions are public endpoints. Revalidate affected paths/tags afterward and return typed results.
### 4. Rendering & UX
- `loading.tsx` + `<Suspense>` to stream slow parts; `error.tsx` for boundaries; `generateStaticParams` to statically render dynamic routes.
- Use the `next/image`, `next/font`, and `<Link>` primitives — they fix common perf/CLS/font issues for free.
## Decision Guide
| Need | Do |
|------|-----|
| Read data for a page | `async` Server Component fetch |
| Always-fresh data | `cache: "no-store"` / `dynamic` |
| Rebuild every N seconds | `next: { revalidate: N }` (ISR) |
| Invalidate after a write | `revalidateTag` / `revalidatePath` |
| Interactivity (state/events) | small `"use client"` leaf |
| Mutation/form submit | server action (`"use server"`) |
| Slow section shouldn't block page | `<Suspense>` + `loading.tsx` |
## Common Mistakes
- **`"use client"` at the top of a big tree** → ships everything to the browser. Push it to leaves.
- **Assuming fetches are cached** (Next 15 default is no-cache) → set caching explicitly.
- **Secrets/DB access in a client component** → leaks to the bundle; use `server-only`.
- **Forgetting to revalidate after a server action** → stale UI.
- **`useEffect` data fetching in a page that could be a Server Component** → lose SSR, caching, and SEO.
- **Hydration mismatch** from `Date.now()`/`window`/random in render → guard or move to an effect/client component.
## Examples
**Server Component fetch with ISR + tags**
```tsx
// app/posts/page.tsx
export default async function Posts() {
const posts = await fetch("https://api.example.com/posts", {
next: { revalidate: 60, tags: ["posts"] },
}).then((r) => r.json());
return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>;
}
```
**Server action: validate, authorize, revalidate**
```tsx
// app/actions.ts
"use server";
import { revalidateTag } from "next/cache";
import { z } from "zod";
const Input = z.object({ title: z.string().min(1) });
export async function createPost(formData: FormData) {
const { title } = Input.parse(Object.fromEntries(formData)); // validate
const user = await requireUser(); // authorize
await db.post.create({ data: { title, authorId: user.id } });
revalidateTag("posts");
}
```
## See Also
- `react-expert` — patterns inside client components.
- `typescript-expert` — typing pages, actions, and params.
- `api-design-expert` — route-handler contracts. `tailwind-expert` — styling.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · miaoge-ge/coding-agent-skills | 100 | MIT |
| personamanagmentlayer/pcl | 100 | Apache-2.0 |
| frankxai/claude-skills-library | 95 | MIT |
| S3YED/appie-kit | 95 | MIT |
| wesleyegberto/software-engineering-skills | 90 | MIT |
Database snapshot: 13.11.2026 · package version 11ee83d56221 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 2 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100react-server-components
React Server Components (RSC) for server-side rendering without client JS. Covers Server vs Client components, data fetching patterns, Server Actions, streaming, caching, and Next.js App Router integration. USE WHEN: user mentions "Server Components", "RSC", "Next.js App… - 85nextjs
Use when writing or reviewing a Next.js App Router project — choosing server or client components, fetching and caching data, server actions, or route handlers. - 100nextjs-app-router-expert
Expert in Next.js 14/15 App Router architecture, React Server Components (RSC), Server Actions, and modern full-stack React development. Specializes in routing patterns, data fetching strategies, caching, streaming, and deployment optimization. Use when the user explicitly needs… - 100nextjs-app-router
Use when implementing or reviewing a Next.js App Router application with server and client components, route handlers, middleware, caching, authentication, streaming, or deployment. Use react-development for framework-neutral components and api-design-first for external APIs. - 90local-nextjs-6b5defe8
Next.js App Router expert guidance. Use when building, debugging, or architecting Next.js applications — routing, Server Components, Server Actions, Cache Components, layouts, middleware/proxy, data fetching, rendering strategies, and deployment on Vercel. - 100nextjs-server-components
Use this skill when the user says 'Next.js server components', 'fetch data in a server component', 'Next.js streaming', 'loading.tsx', 'Suspense in Next.js', 'reduce client JS in Next.js', 'hydration error', 'server actions in Next.js', 'parallel data fetching Next.js'. It…