next-best-practices
できること
このスキルは、Next.js アプリを作るための現在の規則をエージェントに示します。ファイルの構造、コンポーネントの境界、非同期の値、エラーページについて、最新の慣習にコードを合わせたい開発者向けです。
使う場面
- ✓Next.js のページ、ルート、レイアウトを作成または確認するとき。
- ✓サーバーコンポーネントとクライアントコンポーネントの境界を確認したいとき。
- ✓古い Next.js のプロジェクトを、新しい非同期のパターンに更新するとき。
スキルのリンク
https://github.com/Kiranism/next-shadcn-dashboard-starter/blob/main/.agents/skills/next-best-practices/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“この Next.js のページをレビューして、現在のベストプラクティスに従っているか教えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、ファイル構造、コンポーネントの境界、非同期の値、エラーページ、画像やフォントの使い方に関する規則に照らしてコードを確認します。現在のバージョンに合う修正を提案します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Next.js Best Practices
Apply these rules when writing or reviewing Next.js code.
File Conventions
See file-conventions.md for:
- Project structure and special files
- Route segments (dynamic, catch-all, groups)
- Parallel and intercepting routes
- Middleware rename in v16 (middleware → proxy)
RSC Boundaries
Detect invalid React Server Component patterns.
See rsc-boundaries.md for:
- Async client component detection (invalid)
- Non-serializable props detection
- Server Action exceptions
Async Patterns
Next.js 15+ async API changes.
See async-patterns.md for:
- Async
paramsandsearchParams - Async
cookies()andheaders() - Migration codemod
Runtime Selection
See runtime-selection.md for:
- Default to Node.js runtime
- When Edge runtime is appropriate
Directives
See directives.md for:
'use client','use server'(React)'use cache'(Next.js)
Functions
See functions.md for:
- Navigation hooks:
useRouter,usePathname,useSearchParams,useParams - Server functions:
cookies,headers,draftMode,after - Generate functions:
generateStaticParams,generateMetadata
Error Handling
See error-handling.md for:
error.tsx,global-error.tsx,not-found.tsxredirect,permanentRedirect,notFoundforbidden,unauthorized(auth errors)unstable_rethrowfor catch blocks
Data Patterns
See data-patterns.md for:
- Server Components vs Server Actions vs Route Handlers
- Avoiding data waterfalls (
Promise.all, Suspense, preload) - Client component data fetching
Route Handlers
See route-handlers.md for:
route.tsbasics- GET handler conflicts with
page.tsx - Environment behavior (no React DOM)
- When to use vs Server Actions
Metadata & OG Images
See metadata.md for:
- Static and dynamic metadata
generateMetadatafunction- OG image generation with
next/og - File-based metadata conventions
Image Optimization
See image.md for:
- Always use
next/imageover<img> - Remote images configuration
- Responsive
sizesattribute - Blur placeholders
- Priority loading for LCP
Font Optimization
See font.md for:
next/fontsetup- Google Fonts, local fonts
- Tailwind CSS integration
- Preloading subsets
Bundling
See bundling.md for:
- Server-incompatible packages
- CSS imports (not link tags)
- Polyfills (already included)
- ESM/CommonJS issues
- Bundle analysis
Scripts
See scripts.md for:
next/scriptvs native script tags- Inline scripts need
id - Loading strategies
- Google Analytics with
@next/third-parties
Hydration Errors
See hydration-error.md for:
- Common causes (browser APIs, dates, invalid HTML)
- Debugging with error overlay
- Fixes for each cause
Suspense Boundaries
See suspense-boundaries.md for:
- CSR bailout with
useSearchParamsandusePathname - Which hooks require Suspense boundaries
Parallel & Intercepting Routes
See parallel-routes.md for:
- Modal patterns with
@slotand(.)interceptors default.tsxfor fallbacks- Closing modals correctly with
router.back()
Self-Hosting
See self-hosting.md for:
output: 'standalone'for Docker- Cache handlers for multi-instance ISR
- What works vs needs extra setup
Debug Tricks
See debug-tricks.md for:
- MCP endpoint for AI-assisted debugging
- Rebuild specific routes with
--debug-build-paths
よくある質問
最新の Next.js のバージョンも扱いますか?
スキルは、Next.js 15 以降のパターンを扱い、バージョン16でのミドルウェアの名称変更も含みます。
サーバーコンポーネントとは何ですか?
ページの一部がサーバー上で動く部分のことで、規則はそれをクライアントのコードとどう組み合わせられるかを定めています。
エラーページも扱いますか?
はい。エラーページ、グローバルエラー、見つからないページの規則を含みます。
詳細
作者による元の説明
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
人気
- GitHubのスター
- 7.2k
- ランキング
- #13310
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
kiranism-shadcn-dashboard
7.2kNext.js の管理用ダッシュボードのテンプレートに、ページ、表、フォーム、ナビゲーション、テーマを追加するよう、テンプレート自身のパターンに従ってエージェントを支援します。
tanstack-form
7.2kReact などのフレームワークで、フィールドの検査、繰り返しのフィールド、スキーマによる検証を含む、型安全なフォームを作るようエージェントを支援します。
tanstack-query
7.2kTanStack Query で、React アプリのデータの読み込み、更新、キャッシュ、データの変更を扱うようエージェントを支援します。サスペンスによる読み込みも含みます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。