nextjs-rsc-payload-slim
Skill0 starsChanged 5 months agoMITView on GitHub
Next.js App RouterのページHTMLが異常に重い(数百KB)/ LCPが遅い時に発火。DBのselect('*')がclient componentに渡りRSC flightペイロードに全文が直列化されるパターンの診断と修正手順
In this repository99 other files it gives its agents.
- agents-tools-quoted-jsonSkill
- asc-api-app-store-submitSkill
- asd-ste100Skill
- automation-bool-selector-pitfallsSkill
- automation-stale-cooldown-flagSkill
- autonomous-build-verifySkill
- book-to-skillSkill
- ccusage-cli-cost-trackingSkill
- chrome-ext-mv3-programmatic-injectSkill
- chrome-ext-store-assetsSkill
- claude-headless-p-invocationSkill
- claude-plugin-context-auditSkill
- claude-session-log-to-kbSkill
- cloudflare-workers-do-deploySkill
- codebase-to-courseSkill
- codesign-keychain-prompt-fixSkill
- codex-cli-setupSkill
- codex-delegation-handoffSkill
- content-factory-grounding-dedupSkill
- conversation-log-append-patternSkill
- cron-to-launchd-macosSkill
- cross-automation-shared-resource-killSkill
- design-token-migration-rnSkill
- discord-bot-image-to-claudeSkill
- discord-gateway-resume-dedupSkill
- excel-filtered-url-http-auditSkill
- execution-budget-vs-capsSkill
- expo-free-local-ios-testflightSkill
- ga4-connect-projectsSkill
- gcal-oauth-desktop-setupSkill
- git-commit-helperSkill
- git-prepush-secret-remote-checkSkill
- gsc-cli-automationSkill
- hatena-blogsync-autopostSkill
- hook-latency-wrapSkill
- hook-log-append-patternSkill
- html-to-pdf-slide-deckSkill
- humanizerSkill
- human-review-gate-shellSkill
- implementation-model-routingSkill
- insights-to-claude-mdSkill
- ios-permission-key-security-matrixSkill
- ios-sim-store-screenshotsSkill
- launchd-exit78-exconfig-debugSkill
- llm-content-pipeline-quality-gateSkill
- local-ai-video-pipelineSkill
- local-flux-mflux-image-genSkill
- local-llm-slow-diagnosisSkill
- local-music-generationSkill
- lottie-skottie-authoring-pitfallsSkill
- machine-wide-api-ratelimit-latchSkill
- macos-hook-path-timeoutSkill
- md-to-docx-reportSkill
- memory-md-inject-bloat-auditSkill
- message-display-secrets-maskSkill
- metric-source-attributionSkill
- migrate-icloud-desktop-assetsSkill
- nextauth-local-e2e-sessionSkill
- nothing-designSkill
- openclaw-ollama-setupSkill
- The first 60 shown.
The file
Files
Next.js RSCペイロード肥大の診断と修正
Procedure
- 計測:
curl -s -o /tmp/page.html -w "%{size_download}" <URL>(生サイズ)と-H "Accept-Encoding: gzip"(転送サイズ)。grep -o 'self.__next_f.push' /tmp/page.html | wc -lでflightチャンク数を見る。HTML数百KB+チャンク多数なら本パターン濃厚。 - 犯人特定: ページのサーバーコンポーネントから client component('use client')に渡している props を追う。DB層(Supabase/Prisma/Drizzle)で
select('*')が長文カラム(content/body/description等)込みで返していないか grep。client componentに渡したオブジェクトは全フィールドがflightに直列化される(サーバーで使わなくても)。 - 修正: 一覧・カード表示用の軽量型を定義(例
ArticleListItem = Omit<Article,'content'>+ 派生値)。長文から計算する派生値(読了時間等)はサーバー側で事前計算してフィールド化(reading_min: Math.ceil(content.length/400))。DB→サーバー間は select('*') のままでも害は小さい(問題はHTML/flightに乗ること)。全コール経路(一覧API・likes API等のJSONレスポンス含む)を同じ型に統一。 - 検証: 本番ビルド(
next build && next start)でcurl再計測。devサーバーはHMRペイロードが乗るので比較に使わない。
Pitfalls
- カード側が
article.content.length等で長文を1箇所だけ参照していると型エラーで発覚する。削るのではなく事前計算フィールドに置換(UX維持)。 select('*')が複数関数にコピペ増殖している(getArticles/getArticlesByTag/likes API…)。1関数直して満足しない。全経路をgrepすること。- ISR(revalidate)ページはデプロイ直後にキャッシュが切り替わるので、計測は新デプロイ確認後に。
- ついでに直すと良い同根バグ: 一覧orderがslug文字列昇順(1,10,100…)になっている「新着」表示、published フィルタ漏れ。
Verification
- 実例: 就活ナビ(seo-affiliate-site)トップ 493KB→189KB(-62%)。commit 66de8f5(2026-06-12)。
- 成功判定: 生HTMLが数十〜200KB台、flight内に長文カラムの中身が無い(
grep "本文の冒頭数語" /tmp/page.htmlがヒットしない)。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

