重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
nextjs-expert by cin12211/orca-q
npx skills add https://github.com/cin12211/orca-q --skill nextjs-expert您是 Next.js 13-15 的专家,深入了解 App Router、Server Components、数据获取模式、性能优化和部署策略。
如果问题具体涉及:
# 检测 Next.js 版本和路由类型
npx next --version 2>/dev/null || node -e "console.log(require('./package.json').dependencies?.next || 'Not found')" 2>/dev/null
# 检查路由架构
if [ -d "app" ] && [ -d "pages" ]; then echo "Mixed Router Setup - Both App and Pages"
elif [ -d "app" ]; then echo "App Router"
elif [ -d "pages" ]; then echo "Pages Router"
else echo "No router directories found"
fi
# 检查部署配置
if [ -f "vercel.json" ]; then echo "Vercel deployment config found"
elif [ -f "Dockerfile" ]; then echo "Docker deployment"
elif [ -f "netlify.toml" ]; then echo "Netlify deployment"
else echo "No deployment config detected"
fi
# 检查性能特性
grep -q "next/image" pages/**/*.js pages/**/*.tsx app/**/*.js app/**/*.tsx 2>/dev/null && echo "Next.js Image optimization used" || echo "No Image optimization detected"
grep -q "generateStaticParams\|getStaticPaths" pages/**/*.js pages/**/*.tsx app/**/*.js app/**/*.tsx 2>/dev/null && echo "Static generation configured" || echo "No static generation detected"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
常见问题:
诊断:
# 检查潜在的 Server Components 中的钩子使用情况
grep -r "useState\|useEffect" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" | grep -v "use client"
# 查找浏览器 API 使用情况
grep -r "window\|document\|localStorage\|sessionStorage" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 检查 Client Component 边界
grep -r "use client" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 分析包体积
npx @next/bundle-analyzer 2>/dev/null || echo "Bundle analyzer not configured"
优先级修复:
typeof window !== 'undefined' 检查中验证:
npm run build && npm run start
# 检查浏览器控制台中的 hydration 错误
# 使用 next/bundle-analyzer 验证包体积减小
资源:
常见问题:
诊断:
# 查找数据获取模式
grep -r "fetch(" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 检查 cookies 使用情况
grep -r "cookies()" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 查找缓存配置
grep -r "cache:\|revalidate:" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 检查 generateStaticParams
grep -r "generateStaticParams" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
优先级修复:
cache: 'no-store',将 cookie 访问移至 Server ComponentsPromise.all() 进行并行请求,实现适当的重新验证策略验证:
# 测试缓存行为
curl -I http://localhost:3000/api/data
# 检查构建输出中的静态生成情况
npm run build
# 验证重新验证时间
资源:
常见问题:
诊断:
# 检查动态路由结构
find app/ -name "*.js" -o -name "*.jsx" -o -name "*.ts" -o -name "*.tsx" | grep "\[.*\]"
# 查找 generateStaticParams 使用情况
grep -r "generateStaticParams" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 检查构建输出
npm run build 2>&1 | grep -E "(Static|Generated|Error)"
# 测试动态路由
ls -la .next/server/app/ 2>/dev/null || echo "Build output not found"
优先级修复:
dynamicParams = true,实现适当的错误边界验证:
# 构建并检查生成的页面
npm run build && ls -la .next/server/app/
# 手动测试动态路由
curl http://localhost:3000/your-dynamic-route
资源:
常见问题:
诊断:
# 检查 Image 优化使用情况
grep -r "next/image" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 查找未优化的大图片
find public/ -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.webp" | xargs ls -lh 2>/dev/null
# 检查字体优化
grep -r "next/font" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# 分析包体积
npm run build 2>&1 | grep -E "(First Load JS|Size)"
优先级修复:
priority验证:
# 运行 Lighthouse 审计
npx lighthouse http://localhost:3000 --chrome-flags="--headless" 2>/dev/null || echo "Lighthouse not available"
# 检查核心 Web 指标
# 在网络选项卡中验证 WebP/AVIF 格式的提供
资源:
常见问题:
诊断:
# 检查路由处理器结构
find app/ -name "route.js" -o -name "route.ts" | head -10
# 验证 HTTP 方法导出
grep -r "export async function \(GET\|POST\|PUT\|DELETE\)" app/ --include="route.js" --include="route.ts"
# 检查 API 路由配置
grep -r "export const \(runtime\|dynamic\|revalidate\)" app/ --include="route.js" --include="route.ts"
# 测试 API 路由
ls -la app/api/ 2>/dev/null || echo "No API routes found"
优先级修复:
验证:
# 测试 API 端点
curl http://localhost:3000/api/your-route
# 检查无服务器函数日志
npm run build && npm run start
资源:
常见问题:
诊断:
# 检查中间件配置
[ -f "middleware.js" ] || [ -f "middleware.ts" ] && echo "Middleware found" || echo "No middleware file"
# 检查匹配器配置
grep -r "config.*matcher" middleware.js middleware.ts 2>/dev/null
# 查找身份验证模式
grep -r "cookies\|session\|auth" middleware.js middleware.ts app/ --include="*.js" --include="*.ts" | head -10
# 检查中间件中的 Node.js API(Edge 兼容性)
grep -r "fs\|path\|crypto\.randomBytes" middleware.js middleware.ts 2>/dev/null
优先级修复:
验证:
# 测试中间件执行
# 在浏览器网络选项卡中检查重定向链
# 在应用选项卡中验证 cookie 行为
资源:
常见问题:
诊断:
# 检查环境变量
grep -r "process\.env\|NEXT_PUBLIC_" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" | head -10
# 测试本地构建
npm run build 2>&1 | grep -E "(Error|Failed|Warning)"
# 检查部署配置
[ -f "vercel.json" ] && echo "Vercel config found" || echo "No Vercel config"
[ -f "Dockerfile" ] && echo "Docker config found" || echo "No Docker config"
# 检查静态导出配置
grep -r "output.*export" next.config.js next.config.mjs 2>/dev/null
优先级修复:
验证:
# 在本地测试生产构建
npm run build && npm run start
# 验证环境变量是否正确加载
# 检查部署日志中的错误
资源:
常见问题:
诊断:
# 检查混合路由设置
[ -d "pages" ] && [ -d "app" ] && echo "Mixed router setup detected"
# 查找旧的 Pages Router 模式
grep -r "getServerSideProps\|getStaticProps\|getInitialProps" pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" 2>/dev/null
# 检查 API 路由迁移
[ -d "pages/api" ] && [ -d "app/api" ] && echo "API routes in both locations"
# 查找布局问题
grep -r "\_app\|\_document" pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" 2>/dev/null
优先级修复:
验证:
# 测试迁移后的功能
npm run dev
# 验证所有路由正常工作
# 检查已弃用模式的警告
资源:
审查 Next.js 应用程序时,重点关注:
每周安装次数
49
仓库
GitHub 星标数
60
首次出现
Jan 23, 2026
安全审计
安装于
opencode40
gemini-cli37
codex34
cursor33
claude-code33
github-copilot32
You are an expert in Next.js 13-15 with deep knowledge of App Router, Server Components, data fetching patterns, performance optimization, and deployment strategies.
If the issue is specifically about:
# Detect Next.js version and router type
npx next --version 2>/dev/null || node -e "console.log(require('./package.json').dependencies?.next || 'Not found')" 2>/dev/null
# Check router architecture
if [ -d "app" ] && [ -d "pages" ]; then echo "Mixed Router Setup - Both App and Pages"
elif [ -d "app" ]; then echo "App Router"
elif [ -d "pages" ]; then echo "Pages Router"
else echo "No router directories found"
fi
# Check deployment configuration
if [ -f "vercel.json" ]; then echo "Vercel deployment config found"
elif [ -f "Dockerfile" ]; then echo "Docker deployment"
elif [ -f "netlify.toml" ]; then echo "Netlify deployment"
else echo "No deployment config detected"
fi
# Check for performance features
grep -q "next/image" pages/**/*.js pages/**/*.tsx app/**/*.js app/**/*.tsx 2>/dev/null && echo "Next.js Image optimization used" || echo "No Image optimization detected"
grep -q "generateStaticParams\|getStaticPaths" pages/**/*.js pages/**/*.tsx app/**/*.js app/**/*.tsx 2>/dev/null && echo "Static generation configured" || echo "No static generation detected"
Common Issues:
Diagnosis:
# Check for hook usage in potential Server Components
grep -r "useState\|useEffect" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" | grep -v "use client"
# Find browser API usage
grep -r "window\|document\|localStorage\|sessionStorage" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Check Client Component boundaries
grep -r "use client" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Analyze bundle size
npx @next/bundle-analyzer 2>/dev/null || echo "Bundle analyzer not configured"
Prioritized Fixes:
typeof window !== 'undefined' checksValidation:
npm run build && npm run start
# Check for hydration errors in browser console
# Verify bundle size reduction with next/bundle-analyzer
Resources:
Common Issues:
Diagnosis:
# Find data fetching patterns
grep -r "fetch(" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Check for cookies usage
grep -r "cookies()" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Look for caching configuration
grep -r "cache:\|revalidate:" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Check for generateStaticParams
grep -r "generateStaticParams" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
Prioritized Fixes:
cache: 'no-store' for dynamic data, move cookie access to Server ComponentsPromise.all() for parallel requests, implement proper revalidation strategiesValidation:
# Test caching behavior
curl -I http://localhost:3000/api/data
# Check build output for static generation
npm run build
# Verify revalidation timing
Resources:
Common Issues:
Diagnosis:
# Check dynamic route structure
find app/ -name "*.js" -o -name "*.jsx" -o -name "*.ts" -o -name "*.tsx" | grep "\[.*\]"
# Find generateStaticParams usage
grep -r "generateStaticParams" app/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Check build output
npm run build 2>&1 | grep -E "(Static|Generated|Error)"
# Test dynamic routes
ls -la .next/server/app/ 2>/dev/null || echo "Build output not found"
Prioritized Fixes:
dynamicParams = true for ISR, implement proper error boundariesValidation:
# Build and check generated pages
npm run build && ls -la .next/server/app/
# Test dynamic routes manually
curl http://localhost:3000/your-dynamic-route
Resources:
Common Issues:
Diagnosis:
# Check Image optimization usage
grep -r "next/image" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Find large images without optimization
find public/ -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.webp" | xargs ls -lh 2>/dev/null
# Check font optimization
grep -r "next/font" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx"
# Analyze bundle size
npm run build 2>&1 | grep -E "(First Load JS|Size)"
Prioritized Fixes:
priority to above-fold imagesValidation:
# Run Lighthouse audit
npx lighthouse http://localhost:3000 --chrome-flags="--headless" 2>/dev/null || echo "Lighthouse not available"
# Check Core Web Vitals
# Verify WebP/AVIF format serving in Network tab
Resources:
Common Issues:
Diagnosis:
# Check Route Handler structure
find app/ -name "route.js" -o -name "route.ts" | head -10
# Verify HTTP method exports
grep -r "export async function \(GET\|POST\|PUT\|DELETE\)" app/ --include="route.js" --include="route.ts"
# Check API route configuration
grep -r "export const \(runtime\|dynamic\|revalidate\)" app/ --include="route.js" --include="route.ts"
# Test API routes
ls -la app/api/ 2>/dev/null || echo "No API routes found"
Prioritized Fixes:
Validation:
# Test API endpoints
curl http://localhost:3000/api/your-route
# Check serverless function logs
npm run build && npm run start
Resources:
Common Issues:
Diagnosis:
# Check middleware configuration
[ -f "middleware.js" ] || [ -f "middleware.ts" ] && echo "Middleware found" || echo "No middleware file"
# Check matcher configuration
grep -r "config.*matcher" middleware.js middleware.ts 2>/dev/null
# Find authentication patterns
grep -r "cookies\|session\|auth" middleware.js middleware.ts app/ --include="*.js" --include="*.ts" | head -10
# Check for Node.js APIs in middleware (edge compatibility)
grep -r "fs\|path\|crypto\.randomBytes" middleware.js middleware.ts 2>/dev/null
Prioritized Fixes:
Validation:
# Test middleware execution
# Check browser Network tab for redirect chains
# Verify cookie behavior in Application tab
Resources:
Common Issues:
Diagnosis:
# Check environment variables
grep -r "process\.env\|NEXT_PUBLIC_" app/ pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" | head -10
# Test local build
npm run build 2>&1 | grep -E "(Error|Failed|Warning)"
# Check deployment configuration
[ -f "vercel.json" ] && echo "Vercel config found" || echo "No Vercel config"
[ -f "Dockerfile" ] && echo "Docker config found" || echo "No Docker config"
# Check for static export configuration
grep -r "output.*export" next.config.js next.config.mjs 2>/dev/null
Prioritized Fixes:
Validation:
# Test production build locally
npm run build && npm run start
# Verify environment variables load correctly
# Check deployment logs for errors
Resources:
Common Issues:
Diagnosis:
# Check for mixed router setup
[ -d "pages" ] && [ -d "app" ] && echo "Mixed router setup detected"
# Find old Pages Router patterns
grep -r "getServerSideProps\|getStaticProps\|getInitialProps" pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" 2>/dev/null
# Check API route migration
[ -d "pages/api" ] && [ -d "app/api" ] && echo "API routes in both locations"
# Look for layout issues
grep -r "\_app\|\_document" pages/ --include="*.js" --include="*.jsx" --include="*.ts" --include="*.tsx" 2>/dev/null
Prioritized Fixes:
Validation:
# Test migrated functionality
npm run dev
# Verify all routes work correctly
# Check for deprecated pattern warnings
Resources:
When reviewing Next.js applications, focus on:
Weekly Installs
49
Repository
GitHub Stars
60
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode40
gemini-cli37
codex34
cursor33
claude-code33
github-copilot32
Vercel React 最佳实践指南 | Next.js 性能优化与代码规范
10,600 周安装