Communitygithub.com

YepAPI/skills

始终使用 App Router、Server Components 以及现代 Next.js 15 模式——不再有 Pages Router 的幻觉。

skills 是什么?

该技能为使用 Next.js 15 的开发者提供了一套严格的编码规则,旨在引导他们从旧的 Pages Router 模式完全迁移到新的 App Router 架构。它强制要求默认使用 Server Components,并且仅在处理状态、副作用或浏览器 API 等必需场景时使用 `"use client"` 指令。技能详细列出了在元数据处理、数据变更、图片优化、内部路由以及布局和错误边界定义等多个方面的推荐做法与应避免的旧有模式。通过遵循这些规则,开发者可以编写出更现代化、性能更优且更符合 Next.js 15 设计哲学的代码,完全杜绝了新旧 API 混用的问题。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/nextjs

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Next.js 15

规则

  • 始终使用 App Router(app/ 目录),绝不使用 Pages Router(pages/)
  • 默认使用 Server Components —— 仅在需要时(状态、副作用、浏览器 API)才添加 "use client"
  • 使用 generateMetadata() 生成动态元数据,不要使用 <Head>
  • 对于数据变更使用 Server Actions,不要为简单的表单创建 API 路由
  • 使用 next/image 并指定正确的 width/height 或 fill —— 绝不要使用原生的 <img>
  • 使用 next/link —— 对于内部导航,绝不要使用原生的 <a>
  • 路由处理器位于 app/api/[route]/route.ts —— 导出命名函数(GET、POST)
  • 布局放在 layout.tsx 中,加载状态放在 loading.tsx 中,错误边界放在 error.tsx 中
  • 使用 unstable_cache 或 revalidateTag 实现 ISR —— 不要使用旧的 getStaticProps/getServerSideProps
  • 环境变量:客户端仅使用 NEXT_PUBLIC_ 前缀

避免

  • getServerSideProps、getStaticProps、getStaticPaths —— 这些属于 Pages Router
  • _app.tsx、_document.tsx —— 这些属于 Pages Router
  • 来自 next/router 的 useRouter —— 请使用 next/navigation 代替
  • next/head —— 请使用 generateMetadata 导出
  • 不必要地将 Server Components 包裹在 "use client" 中

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相关技能