Officialコーディング&開発github.com

vercel-react-best-practices

Vercel エンジニアリングチームによる React および Next.js のパフォーマンス最適化ガイドラインです。React/Next.js コードの作成、レビュー、リファクタリング時に最適なパフォーマンスパターンを適用するために使用します。

vercel-react-best-practices とは?

Vercel React Best Practices スキルは、Vercel が管理する React および Next.js アプリケーション向けの包括的なパフォーマンス最適化ガイドです。70 のルールが 8 つのカテゴリに分かれており、影響度に基づいて優先順位付けされています。このスキルは、新しい React コンポーネントや Next.js ページの作成、データフェッチ(クライアント/サーバーサイド)の実装、パフォーマンス問題のレビュー、既存 React/Next.js コードのリファクタリング、バンドルサイズや読み込み時間の最適化時に自動リファクタリングやコード生成のガイドとして機能します。ルールカテゴリは、クリティカルな「ウォーターフォールの排除」と「バンドルサイズ最適化」から、高優先度の「サーバーサイドパフォーマンス」、中程度の「クライアントサイドデータフェッチ」、「再レンダリング最適化」、「レンダリングパフォーマンス」、「JavaScript パフォーマンス」、低優先度の「高度なパターン」まで、優先度と影響度に応じて体系的に分類されています。各カテゴリには具体的な実践ルール(非同期処理の並列化、動的インポート、メモ化、コンポーネント構造の最適化など)が含まれており、開発者はコードベースのパフォーマンスを段階的に改善できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Vercel React ベストプラクティス

React および Next.js アプリケーション向けの包括的なパフォーマンス最適化ガイド。Vercel 管理。優先度順に並べられた 8 カテゴリ、70 ルールを含み、自動リファクタリングとコード生成を導きます。

適用タイミング

以下の場合に本ガイドラインを参照してください:

  • 新しい React コンポーネントや Next.js ページを作成するとき
  • データフェッチ(クライアントサイドまたはサーバーサイド)を実装するとき
  • パフォーマンス問題についてコードをレビューするとき
  • 既存の React/Next.js コードをリファクタリングするとき
  • バンドルサイズや読み込み時間を最適化するとき

ルールカテゴリ別優先度

優先度カテゴリ影響プレフィックス
1ウォーターフォールの排除重大async-
2バンドルサイズ最適化重大bundle-
3サーバーサイドパフォーマンス高server-
4クライアントサイドデータフェッチ中-高client-
5再レンダリング最適化中rerender-
6レンダリングパフォーマンス中rendering-
7JavaScript パフォーマンス低-中js-
8高度なパターン低advanced-

クイックリファレンス

1. ウォーターフォールの排除(重大)

  • async-cheap-condition-before-await - フラグやリモート値を待つ前に、安価な同期条件をチェックする
  • async-defer-await - await を実際に使用するブランチ内に移動する
  • async-parallel - 独立した処理には Promise.all() を使う
  • async-dependencies - 部分的な依存関係には better-all を使う
  • async-api-routes - API ルートでは Promise を早く開始し、遅く await する
  • async-suspense-boundaries - Suspense を使ってコンテンツをストリーミングする

2. バンドルサイズ最適化(重大)

  • bundle-barrel-imports - 直接インポートし、バレルファイルを避ける
  • bundle-analyzable-paths - 静的に解析可能なインポートパスとファイルシステムパスを優先し、広範囲なバンドルやトレースを避ける
  • bundle-dynamic-imports - 重いコンポーネントには next/dynamic を使う
  • bundle-defer-third-party - アナリティクス/ロギングはハイドレーション後に読み込む
  • bundle-conditional - 機能が有効な場合のみモジュールを読み込む
  • bundle-preload - ホバー/フォーカス時にプリロードして知覚速度を向上

3. サーバーサイドパフォーマンス(高)

  • server-auth-actions - API ルートと同様にサーバーアクションを認証する
  • server-cache-react - React.cache() を使ってリクエストごとの重複排除を行う
  • server-cache-lru - LRU キャッシュを使ってリクエスト間のキャッシュを行う
  • server-dedup-props - RSC props での重複シリアライズを避ける
  • server-hoist-static-io - 静的 I/O(フォント、ロゴ)をモジュールレベルに引き上げる
  • server-no-shared-module-state - RSC/SSR でモジュールレベルのミュータブルなリクエスト状態を避ける
  • server-serialization - クライアントコンポーネントに渡すデータを最小化する
  • server-parallel-fetching - コンポーネントを再構成してフェッチを並列化する
  • server-parallel-nested-fetching - Promise.all 内でアイテムごとにネストされたフェッチをチェーンする
  • server-after-nonblocking - ノンブロッキング処理には after() を使う

4. クライアントサイドデータフェッチ(中-高)

  • client-swr-dedup - SWR を使って自動リクエスト重複排除を行う
  • client-event-listeners - グローバルイベントリスナーを重複排除する
  • client-passive-event-listeners - スクロールにはパッシブリスナーを使う
  • client-localstorage-schema - localStorage データのバージョン管理と最小化

5. 再レンダリング最適化(中)

  • rerender-defer-reads - コールバックでのみ使用する状態を購読しない
  • rerender-memo - 重い処理をメモ化されたコンポーネントに抽出する
  • rerender-memo-with-default-value - デフォルトの非プリミティブな props をホイストする
  • rerender-dependencies - エフェクトではプリミティブな依存関係を使う
  • rerender-derived-state - 生の値ではなく、派生した真偽値を購読する
  • rerender-derived-state-no-effect - エフェクトではなくレンダリング中に状態を派生させる
  • rerender-functional-setstate - 安定したコールバックのために関数型 setState を使う
  • rerender-lazy-state-init - 高コストな値には関数を useState に渡す
  • rerender-simple-expression-in-memo - 単純なプリミティブには memo を避ける
  • rerender-split-combined-hooks - 独立した依存関係を持つフックを分割する
  • rerender-move-effect-to-event - インタラクションロジックをイベントハンドラーに移動する
  • rerender-transitions - 緊急でない更新には startTransition を使う
  • rerender-use-deferred-value - 高コストなレンダリングを遅延させて入力をレスポンシブに保つ
  • rerender-use-ref-transient-values - 一時的な頻繁な値には refs を使う
  • rerender-no-inline-components - コンポーネント内でコンポーネントを定義しない

6. レンダリングパフォーマンス(中)

  • rendering-animate-svg-wrapper - SVG 要素ではなく div ラッパーをアニメーションする
  • rendering-content-visibility - 長いリストには content-visibility を使う
  • rendering-hoist-jsx - 静的な JSX をコンポーネントの外に引き上げる
  • rendering-svg-precision - SVG 座標の精度を下げる
  • rendering-hydration-no-flicker - クライアント専用データにはインラインスクリプトを使う
  • rendering-hydration-suppress-warning - 予期される不一致を抑制する
  • rendering-activity - 表示/非表示には Activity コンポーネントを使う
  • rendering-conditional-render - 条件分岐には && ではなく三項演算子を使う
  • rendering-usetransition-loading - ローディング状態には useTransition を優先する
  • rendering-resource-hints - プリロードには React DOM のリソースヒントを使う
  • rendering-script-defer-async - script タグには defer または async を使う

7. JavaScript パフォーマンス(低-中)

  • js-batch-dom-css - クラスや cssText を使って CSS 変更をグループ化する
  • js-index-maps - 繰り返しのルックアップには Map を構築する
  • js-cache-property-access - ループ内でオブジェクトのプロパティをキャッシュする
  • js-cache-function-results - 関数の結果をモジュールレベルの Map にキャッシュする
  • js-cache-storage - localStorage/sessionStorage の読み取りをキャッシュする
  • js-combine-iterations - 複数の filter/map を 1 つのループに結合する
  • js-length-check-first - 高コストな比較の前に配列の長さをチェックする
  • js-early-exit - 関数から早期に return する
  • js-hoist-regexp - RegExp の生成をループの外に引き上げる
  • js-min-max-loop - 最小/最大を求めるには sort ではなくループを使う
  • js-set-map-lookups - Set/Map を使って O(1) のルックアップを実現する
  • js-tosorted-immutable - 不変性のために toSorted() を使う
  • js-flatmap-filter - flatMap を使ってマッピングとフィルタリングを 1 パスで行う
  • js-request-idle-callback - 重要でない処理をブラウザのアイドル時間に遅延させる

8. 高度なパターン(低)

  • advanced-effect-event-deps - useEffectEvent の結果をエフェクトの依存関係に含めない
  • advanced-event-handler-refs - イベントハンドラーを refs に格納する
  • advanced-init-once - アプリの読み込みごとに 1 回だけ初期化する
  • advanced-use-latest - 安定したコールバック refs のために useLatest を使う

使い方

詳細な説明とコード例については個別のルールファイルを参照してください:

rules/async-parallel.md
rules/bundle-barrel-imports.md

各ルールファイルの内容:

  • 重要である理由の簡単な説明
  • 説明付きの誤ったコード例
  • 説明付きの正しいコード例
  • 追加のコンテキストと参考資料

完全版ドキュメント

すべてのルールを展開した完全ガイド:AGENTS.md

Individual skills in this repo

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

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

vercel-cli-with-tokens

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g.

vercel-composition-patterns

React composition patterns that scale. Use when refactoring components with

vercel-labs/vercel-composition-patterns

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

vercel-labs/vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-labs/vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

vercel-labs/vercel-react-view-transitions

Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.

vercel-optimize

Use for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps. Collect Vercel metrics, usage, project config, and code scan results first; investigate only metric-backed candidates; produce ranked recommendations grounded in verified files and version-aware Vercel/framework docs. Trigger for Vercel bill reduction, slow or expensive routes, caching opportunities, Function Invocations, Build Minutes, Fast Data Transfer, Core Web Vitals, Bot Management, Fluid compute, or cost breakdown requests.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use

web-design-guidelines

Review UI code for Web Interface Guidelines compliance. Use when asked to

writing-guidelines

Review docs/prose for Writing Guidelines compliance. Use when asked to

関連スキル