NextJS
暂无简介
- License 许可
- MIT
- 所属仓库
- iberi22/skills
- 最近更新
- 2026-10-12
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- id
- nextjs
- name
- NextJS
- tags
- [ "nextjs" ]
- goals
- [ "Build Next.js 15 apps with App Router, server components, caching, auth, and production patterns." ]
- category
- framework
03 SKILL.md 正文
When to Use
User needs Next.js expertise — routing, data fetching, caching, authentication, or deployment. Agent handles App Router patterns, server/client boundaries, and production optimization.
Core Rules
1. Server Components by Default
Everything is Server Component in App Router. Add 'use client' only for useState, useEffect, event handlers, or browser APIs. Server Components can't be imported into Client — pass as children.
2. Fetch Data on Server
Fetch in Server Components, not useEffect. Use Promise.all for parallel requests.
3. Cache Intentionally
fetch is not cached by default in Next.js 15 — opt in with cache: 'force-cache' or set revalidate for ISR.
4. Server Actions for Mutations
Use 'use server' functions for form submissions and data mutations. Progressive enhancement — works without JS.
5. Environment Security
NEXT_PUBLIC_ exposes to client bundle. Server Components access all env vars. Use .env.local for secrets.
6. Streaming for Large Data
Use <Suspense> boundaries to stream content progressively. Wrap slow components individually.
7. Auth at Middleware Level
Protect routes in middleware, not in pages. Middleware runs on Edge — lightweight auth checks only.
Server vs Client
| Server Component | Client Component |
|---|---|
| Default in App Router | Requires 'use client' |
| Can be async | Cannot be async |
| Access backend, env vars | Access hooks, browser APIs |
| Zero JS shipped | JS shipped to browser |
Decision: Start Server. Add 'use client' only for: useState, useEffect, onClick, browser APIs.
Common Traps
| Trap | Fix |
|---|---|
router.push in Server |
Use redirect() |
<Link> prefetches all |
prefetch={false} |
next/image no size |
Add width/height or fill |
| Metadata in Client | Move to Server or generateMetadata |
| useEffect for data | Fetch in Server Component |
| Import Server→Client | Pass as children/props |
| Middleware DB call | Call API route instead |
Missing await params (v15) |
Params are async in Next.js 15 |
Next.js 15 Changes
paramsandsearchParamsare nowPromise— must awaitfetchnot cached by default — opt-in withcache: 'force-cache'- Use React 19 hooks:
useActionState,useFormStatus
Related Skills
Related skills to install if relevant:
react— React fundamentals and patternstypescript— Type safety for better DXprisma— Database ORM for Next.js appstailwindcss— Styling with utility classesnodejs— Server runtime knowledge
04 同仓库更多 Skills
web-design-guidelines
暂无简介
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall. Recovers the page via archives and provenance-checked fallbacks.
studio-coach
暂无简介
src-generator
暂无简介
sqlite-pro
暂无简介
rigor-evaluator
Use when you need a quick heuristic rigor score (10 criteria, 0-2 each) for the features in a .gitcore/features.json file, to decide which features are ready to ship.