react-router-loader-performance
React Router v7のローダー処理を高速化し、TTFBの改善やデータベースクエリの最適化、データストリーミングを実現することで、Webサイトの表示速度を向上させるSkill。
📜 元の英語説明(参考)
React Router v7 loader performance optimization techniques. Use when optimizing TTFB, eliminating waterfalls, consolidating database queries, or streaming secondary data in loaders. Triggers on "slow loaders", "optimize TTFB", "speed up React Router", "loader performance", or when loaders exceed 500ms response time.
🇯🇵 日本人クリエイター向け解説
React Router v7のローダー処理を高速化し、TTFBの改善やデータベースクエリの最適化、データストリーミングを実現することで、Webサイトの表示速度を向上させるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o react-router-loader-performance.zip https://jpskill.com/download/9732.zip && unzip -o react-router-loader-performance.zip && rm react-router-loader-performance.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9732.zip -OutFile "$d\react-router-loader-performance.zip"; Expand-Archive "$d\react-router-loader-performance.zip" -DestinationPath $d -Force; ri "$d\react-router-loader-performance.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
react-router-loader-performance.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
react-router-loader-performanceフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
React Router Loader のパフォーマンス
React Router v7 のローダーにおける重要な最適化テクニックです。ウォーターフォールを排除し、並列実行を最大化することに焦点を当てた4つのルールが含まれています。
影響: 非常に重要 - ローダーのパフォーマンスが悪いと、Time To First Byte (TTFB) と体感的なページ速度に直接影響します。
適用するタイミング
以下の状況でこれらのテクニックを使用してください。
- ローダーの TTFB が 500ms を超える場合
- 複数のデータベースクエリが順番に実行される場合
- 二次的なデータ (レコメンデーション、分析) がクリティカルパスをブロックする場合
- データベースのレイテンシが高い (クエリあたり 50ms を超える) 場合
- React Router v7 のデータローディングパターンを最適化する場合
ルールの概要
データベースの最適化 (非常に重要)
loader-consolidate-queries - @rules/loader-consolidate-queries.md
単一のクエリでデータを取得するために、ORM の include/relation を使用します。
// 悪い例: 3 回の DB コール (~150ms のレイテンシで ~450ms)
const product = await db.product.findUnique({ where: { id } });
const reviews = await db.review.findMany({ where: { productId: id } });
const variations = await db.variation.findMany({ where: { productId: id } });
// 良い例: 1 回の DB コール (~200ms)
const product = await db.product.findUnique({
where: { id },
include: { reviews: true, variations: true },
});
影響: 特にレイテンシの高い DB 接続では、ローダーのパフォーマンスを最も大きく改善できることが多いです。
ストリーミングの最適化 (高)
loader-defer-slow-secondary - @rules/loader-defer-slow-secondary.md
重要でないデータは await せずにストリームします。
// 悪い例: 遅い操作でブロックされる (~3500ms TTFB)
const product = await getProduct(id); // 500ms
const recommendations = await getRecommendations(product); // 3000ms
return data({ product, recommendations }); // TTFB: 3500ms
// 良い例: 二次的なデータをストリームする (~500ms TTFB)
const product = await getProduct(id); // 500ms
const recommendations = getRecommendations(product); // await しない
return data({ product, recommendations }); // TTFB: 500ms
影響: 遅い操作をクリティカルパスから外します。ユーザーが製品を見ている間にレコメンデーションがストリームされます。
インフラストラクチャの最適化 (高)
infrastructure-colocation
サーバーとデータベース間の地理的な距離を最小限に抑えます。
主要な指標:
- 同じリージョン: <10ms のレイテンシ
- リージョン間: 50-200ms のレイテンシ
- 大陸間: >100ms のレイテンシ
アクション:
- DB とサーバーを同じクラウドリージョンでホストする
- 読み取り負荷の高いルートでは、アプリケーションサーバーの近くにリードレプリカを使用する
- 一貫して 30ms を超えるレイテンシについて、ORM クエリログを分析する
- DB のレイテンシが高い場合は、コードの最適化よりもインフラストラクチャの変更の方が大きな効果をもたらす
並列実行 (非常に重要)
promise-all-independent
独立した非同期操作には Promise.all を使用します (frontend-async-best-practices で説明)。
// 悪い例: 順番に実行 (~900ms)
const product = await fetchProduct(); // 400ms
const reviews = await fetchReviews(); // 300ms
const variations = await fetchVariations(); // 200ms
// 良い例: 並列実行 (~400ms)
const [product, reviews, variations] = await Promise.all([
fetchProduct(),
fetchReviews(),
fetchVariations(),
]);
影響: 合計時間はすべての操作の合計ではなく、最も遅い操作の時間と等しくなります。
パフォーマンス目標
- TTFB: クリティカルパスで <500ms
- DB レイテンシ: クエリあたり <30ms (ORM ログで測定)
- 二次的なデータ: 重要でない 1000ms を超えるものはすべてストリームする
測定
Server-Timing ヘッダーを使用してボトルネックを特定します。
import { time } from "~/utils/timing.server";
export async function loader({ params }: Route.LoaderArgs) {
const product = await time("product", () => getProduct(params.id));
const recommendations = time("recommendations", () =>
getRecommendations(product)
);
return data({ product, recommendations });
}
Chrome DevTools の Network タブで Server-Timing の内訳を分析します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
React Router Loader Performance
Critical optimization techniques for React Router v7 loaders. Contains 4 rules focused on eliminating waterfalls and maximizing parallel execution.
Impact: CRITICAL - Poor loader performance directly impacts Time To First Byte (TTFB) and perceived page speed.
When to Apply
Use these techniques when:
- Loader TTFB exceeds 500ms
- Multiple database queries execute sequentially
- Secondary data (recommendations, analytics) blocks critical path
- Database latency is high (>50ms per query)
- Optimizing React Router v7 data loading patterns
Rules Summary
Database Optimization (CRITICAL)
loader-consolidate-queries - @rules/loader-consolidate-queries.md
Use ORM includes/relations for single-query data fetching.
// Bad: 3 DB calls (~450ms on 150ms latency)
const product = await db.product.findUnique({ where: { id } });
const reviews = await db.review.findMany({ where: { productId: id } });
const variations = await db.variation.findMany({ where: { productId: id } });
// Good: 1 DB call (~200ms)
const product = await db.product.findUnique({
where: { id },
include: { reviews: true, variations: true },
});
Impact: Often the single biggest loader performance win, especially on high-latency DB connections.
Streaming Optimization (HIGH)
loader-defer-slow-secondary - @rules/loader-defer-slow-secondary.md
Stream non-critical data without awaiting.
// Bad: blocks on slow operation (~3500ms TTFB)
const product = await getProduct(id); // 500ms
const recommendations = await getRecommendations(product); // 3000ms
return data({ product, recommendations }); // TTFB: 3500ms
// Good: streams secondary data (~500ms TTFB)
const product = await getProduct(id); // 500ms
const recommendations = getRecommendations(product); // Don't await
return data({ product, recommendations }); // TTFB: 500ms
Impact: Keeps slow operations off critical path. Recommendations stream while user views product.
Infrastructure Optimization (HIGH)
infrastructure-colocation
Minimize geographic distance between servers and databases.
Key metrics:
- Same region: <10ms latency
- Cross-region: 50-200ms latency
- Cross-continent: >100ms latency
Actions:
- Host DB and servers in same cloud region
- Use read replicas near application servers for read-heavy routes
- Analyze ORM query logs for consistent >30ms latency
- When DB latency is high, infrastructure changes provide greater gains than code optimization
Parallel Execution (CRITICAL)
promise-all-independent
Use Promise.all for independent async operations (covered in frontend-async-best-practices).
// Bad: sequential (~900ms)
const product = await fetchProduct(); // 400ms
const reviews = await fetchReviews(); // 300ms
const variations = await fetchVariations(); // 200ms
// Good: parallel (~400ms)
const [product, reviews, variations] = await Promise.all([
fetchProduct(),
fetchReviews(),
fetchVariations(),
]);
Impact: Total time equals slowest operation, not sum of all operations.
Performance Targets
- TTFB: <500ms for critical path
- DB latency: <30ms per query (measure with ORM logs)
- Secondary data: Stream anything >1000ms that's non-critical
Measurement
Use Server-Timing headers to identify bottlenecks:
import { time } from "~/utils/timing.server";
export async function loader({ params }: Route.LoaderArgs) {
const product = await time("product", () => getProduct(params.id));
const recommendations = time("recommendations", () =>
getRecommendations(product)
);
return data({ product, recommendations });
}
Analyze Chrome DevTools Network tab for Server-Timing breakdown.