AgentSkillsCN

nextjs-app-router

采用服务器优先的模式,结合显式缓存策略、Route Handler 与 Server Action,构建并维护 Next.js App Router 功能。适用于创建或更改路由、布局、服务器动作、认证边界,或数据缓存行为时使用。

SKILL.md
--- frontmatter
name: nextjs-app-router
description: Build and maintain Next.js App Router features with server-first patterns, explicit cache strategy, Route Handlers, and Server Actions. Use when creating or changing routes, layouts, server actions, auth boundaries, or data caching behavior.

Next.js App Router

  • Start from server-first design and move client logic to isolated interactive islands.
  • Keep data writes in Server Actions unless an external HTTP API contract is required.
  • Use Route Handlers only for external API boundaries and webhook style integrations.
  • Keep cache intent explicit and pair every mutation with targeted revalidation.
  • Place auth and role checks close to the write boundary.
  • Reuse logic from packages/domain and packages/db instead of duplicating.