Token导航 LogoToken导航

Agent Skill · 前端设计

nextjs-app-router(Next.js 应用 router)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

nextjs-app-router 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 4,732。

总安装 816周安装 33GitHub Stars 12下载 256核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nextjs-app-router(Next.js 应用 router)
来源仓库:https://github.com/claude-dev-suite/claude-dev-suite
仓库路径:skills/nextjs-app-router
安装命令:
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill nextjs-app-router
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill nextjs-app-router

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

nextjs-app-router 用于辅助前端页面、组件和样式开发,适合生成 React 代码或审查 Next.js 路由结构。它提供 App Router 的文件约定、Server Components 和 API Routes 编写模式,支持 SSR 和静态生成。

使用时需结合项目现有设计系统,避免生成孤立片段;涉及页面改动时应配合本地预览确认视觉效果。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/nextjs-app-router

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill next…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

nextjs-app-router 怎么安装?

在终端执行 npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill nextjs-app-rou…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

nextjs-app-router 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

nextjs-app-router 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

nextjs-app-router 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

nextjs-app-router 用的人多吗?

公开数据是累计安装 816 次,近一周安装 33 次,下载 256 次,GitHub 12 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

nextjs-app-router 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
nextjs-app-router

Next.js 应用 router · 本页

81612接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Next.js App Router Core

Full Reference: See advanced.md for WebSocket integration, Socket.IO, Server-Sent Events, TanStack Query real-time sync, and Vercel/Pusher patterns.
Deep Knowledge: Use mcp__documentation__fetch_docs with technology: nextjs for comprehensive documentation.

File Conventions

FilePurpose
page.tsxRoute UI (required for route)
layout.tsxShared layout, preserves state
loading.tsxLoading UI (Suspense)
error.tsxError boundary
not-found.tsx404 page
route.tsAPI endpoint

Component Types

Server Components (Default)

// No 'use client' - runs on server
async function Page() {
  const data = await db.query(...); // Direct DB access
  return <div>{data.name}</div>;
}

Client Components

'use client'
import { useState } from 'react';

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

Data Fetching

// Server Component
async function Page() {
  const data = await fetch('https://api.example.com/data', {
    cache: 'force-cache',     // Static (default)
    // cache: 'no-store',     // Dynamic
    // next: { revalidate: 60 } // ISR
  });
  return <Component data={await data.json()} />;
}

Server Actions

'use server'
export async function createItem(formData: FormData) {
  await db.items.create({ name: formData.get('name') });
  revalidatePath('/items');
}

Decision Rules

ScenarioUse
Interactive UI'use client'
Data fetchingServer Component
Form mutationsServer Actions
Shared stateClient Component

Production Readiness

Security Configuration

// next.config.js - Security headers
const securityHeaders = [
  { key: 'X-DNS-Prefetch-Control', value: 'on' },
  { key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' },
  { key: 'X-Content-Type-Options', value: 'nosniff' },
  { key: 'X-Frame-Options', value: 'DENY' },
  { key: 'X-XSS-Protection', value: '1; mode=block' },
  { key: 'Referrer-Policy', value: 'origin-when-cross-origin' },
  {
    key: 'Content-Security-Policy',
    value: `default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline';`,
  },
];

module.exports = {
  async headers() {
    return [{ source: '/:path*', headers: securityHeaders }];
  },
};
// Server-side secrets (never exposed to client)
// Use server components or API routes
async function SecureComponent() {
  const apiKey = process.env.API_SECRET_KEY; // Server only
  const data = await fetch(url, { headers: { Authorization: apiKey } });
  return <div>{/* render data */}</div>;
}

// Environment variables
// NEXT_PUBLIC_* = exposed to client (careful!)
// Other vars = server-side only

Error Handling

// app/error.tsx - Error boundary
'use client'

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string }
  reset: () => void
}) {
  useEffect(() => {
    // Log to error reporting service
    captureException(error);
  }, [error]);

  return (
    <div>
      <h2>Something went wrong!</h2>
      <button onClick={reset}>Try again</button>
    </div>
  );
}
// app/global-error.tsx - Root error boundary
'use client'

export default function GlobalError({
  error,
  reset,
}: {
  error: Error & { digest?: string }
  reset: () => void
}) {
  return (
    <html>
      <body>
        <h2>Something went wrong!</h2>
        <button onClick={reset}>Try again</button>
      </body>
    </html>
  );
}

Performance Optimization

// Dynamic imports for client components
import dynamic from 'next/dynamic';

const HeavyChart = dynamic(() => import('@/components/Chart'), {
  loading: () => <Skeleton />,
  ssr: false, // Client-only if needed
});

// Image optimization
import Image from 'next/image';

<Image
  src="/hero.jpg"
  alt="Hero"
  width={1200}
  height={600}
  priority // For LCP images
  placeholder="blur"
  blurDataURL={blurHash}
/>

// Font optimization
import { Inter } from 'next/font/google';
const inter = Inter({ subsets: ['latin'], display: 'swap' });

Caching Strategy

// Static data (cached indefinitely)
async function StaticPage() {
  const data = await fetch(url, { cache: 'force-cache' });
}

// Dynamic data (never cached)
async function DynamicPage() {
  const data = await fetch(url, { cache: 'no-store' });
}

// ISR (revalidate every 60 seconds)
async function ISRPage() {
  const data = await fetch(url, { next: { revalidate: 60 } });
}

// On-demand revalidation
import { revalidatePath, revalidateTag } from 'next/cache';

async function updateData() {
  'use server';
  await db.update(...);
  revalidatePath('/posts');     // Revalidate specific path
  revalidateTag('posts');       // Revalidate by tag
}

Middleware Security

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
  // Rate limiting header for upstream proxy
  const response = NextResponse.next();

  // Auth check
  const token = request.cookies.get('session');
  if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
    return NextResponse.redirect(new URL('/login', request.url));
  }

  // CORS for API routes
  if (request.nextUrl.pathname.startsWith('/api')) {
    response.headers.set('Access-Control-Allow-Origin', process.env.ALLOWED_ORIGIN!);
  }

  return response;
}

export const config = {
  matcher: ['/dashboard/:path*', '/api/:path*'],
};

Monitoring Metrics

MetricAlert Threshold
Largest Contentful Paint (LCP)> 2.5s
First Input Delay (FID)> 100ms
Cumulative Layout Shift (CLS)> 0.1
Time to First Byte (TTFB)> 800ms
Server Component render time> 200ms
Build size increase> 10%

Build & Deployment

// next.config.js - Production optimizations
module.exports = {
  output: 'standalone', // For Docker deployments
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: 'cdn.example.com' },
    ],
  },
  experimental: {
    // Enable if using PPR
    ppr: true,
  },
};
# Production build with analysis
ANALYZE=true npm run build

# Check bundle size
npx @next/bundle-analyzer

Checklist

  • Security headers configured
  • CSP policy defined
  • No secrets in NEXT_PUBLIC_* vars
  • Error boundaries at route level
  • Global error boundary
  • Image optimization with next/image
  • Font optimization with next/font
  • Dynamic imports for heavy components
  • Caching strategy per route
  • Middleware for auth/rate limiting
  • Core Web Vitals monitored
  • Standalone output for containerization

When NOT to Use This Skill

This skill is for Next.js App Router (v13+). DO NOT use for:

  • React without Next.js: Use frontend-react skill instead
  • Next.js Pages Router (v12 and below): Consult KB for migration guidance
  • Nuxt.js (Vue meta-framework): Use nuxt3 skill instead
  • Remix (React meta-framework): Use remix skill instead
  • SvelteKit: Use sveltekit skill instead
  • Astro: Use astro skill instead
  • API-only backend: Consider nestjs or fastapi instead

Anti-Patterns

Anti-PatternWhy It's WrongCorrect Approach
Using 'use client' everywhereDefeats Server Component benefits, increases bundle sizeOnly use 'use client' for interactive components
Fetching in Client ComponentsWaterfalls, no SSR, poor SEOFetch in Server Components or use Server Actions
Not using loading.tsxPoor UX during data fetchingCreate loading.tsx for route-level loading states
Secrets in NEXT_PUBLIC_*Exposed to client, security riskUse server-only env vars or Server Components
Ignoring caching strategyPoor performance or stale dataSet explicit cache: 'force-cache', 'no-store', or revalidate
No error boundariesUncaught errors crash entire appAdd error.tsx at route and root level
fetch() without cache optionUnpredictable caching behaviorAlways specify cache or revalidate strategy
Using useEffect for dataClient-side only, no SSRUse Server Components with async/await

Quick Troubleshooting

IssuePossible CauseSolution
"Cannot use useState in Server Component"Missing 'use client' directiveAdd 'use client' at top of file
Data not updating after mutationCache not revalidatedUse revalidatePath() or revalidateTag() in Server Action
Hydration mismatch errorServer/client render differentlyEnsure consistent data, check Date/random values
"Cannot access cookies" in componentCookies only in Server Components/ActionsMove logic to Server Component or API route
Build fails with "Dynamic server usage"Using dynamic APIs in static routeAdd export const dynamic = 'force-dynamic'
Images not optimizedNot using next/imageReplace with from next/image
Slow page loadLarge client bundleUse dynamic imports, check bundle analyzer
CORS errors with API routesMissing headers in route.tsAdd CORS headers in route handler

Reference Documentation

平台分布

Codex

37.37%
按下载量换算96

Claude

27.12%
按下载量换算69

Cursor

16.77%
按下载量换算43

Gemini CLI

9.48%
按下载量换算24

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills