Communitygithub.com

marnixGeerkens/rocketlauncher-claude-code

Next.js App Routerの原則。サーバーコンポーネント、データフェッチング、ルーティングパターン。

rocketlauncher-claude-code とは?

このスキルは、Next.js App Routerを用いた開発におけるベストプラクティスを提供します。サーバーコンポーネントとクライアントコンポーネントの適切な使い分け、データフェッチング戦略、ルーティングパターン、パフォーマンス最適化、キャッシュ戦略、サーバーアクション、そしてアンチパターンまでを網羅しています。開発者はこのスキルを参照することで、Next.jsアプリケーションの設計と実装において最適なアーキテクチャを選択できるようになります。主にClaude CodeやClineなどのAIエージェントが、ユーザーのコード生成やリファクタリングのリクエストに応じて、このベストプラクティスに基づいたアドバイスや実装例を提供するために利用されます。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/marnixGeerkens/rocketlauncher-claude-code/tree/HEAD/components/skills/development/nextjs-best-practices

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

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

ドキュメント

Next.js ベストプラクティス

Next.js App Router 開発のための原則


1. サーバーコンポーネント vs クライアントコンポーネント

判断フローチャート

何が必要か?
│
├── useState, useEffect, イベントハンドラ
│   └── クライアントコンポーネント ('use client')
│
├── 直接データフェッチ、インタラクティブ不要
│   └── サーバーコンポーネント (デフォルト)
│
└── 両方?
    └── 分割: サーバーペアレント + クライアントチャイルド

デフォルトで

タイプ用途
サーバーデータフェッチ、レイアウト、静的コンテンツ
クライアントフォーム、ボタン、インタラクティブUI

2. データフェッチパターン

フェッチ戦略

パターン用途
Default静的 (ビルド時にキャッシュ)
RevalidateISR (時間ベースのリフレッシュ)
No-store動的 (毎リクエスト)

データフロー

ソースパターン
データベースサーバーコンポーネントでfetch
APIキャッシュ付きfetch
ユーザー入力クライアント状態 + サーバーアクション

3. ルーティングの原則

ファイル規約

ファイル目的
page.tsxルートのUI
layout.tsx共有レイアウト
loading.tsxローディング状態
error.tsxエラーバウンダリ
not-found.tsx404ページ

ルートの構成

パターン用途
ルートグループ (name)URLに影響させずに整理
パラレルルート @slot同じ階層の複数ページ
インターセプト (.)モーダルオーバーレイ

4. APIルート

ルートハンドラ

メソッド用途
GETデータの読み取り
POSTデータの作成
PUT/PATCHデータの更新
DELETEデータの削除

ベストプラクティス

  • Zodで入力をバリデーション
  • 適切なステータスコードを返す
  • エラーを適切に処理
  • 可能な限りEdgeランタイムを使用

5. パフォーマンスの原則

画像最適化

  • next/image コンポーネントを使用
  • ファーストビューにはpriorityを設定
  • blur placeholderを提供
  • レスポンシブサイズを使用

バンドル最適化

  • 重いコンポーネントは動的インポート
  • ルートベースのコード分割(自動)
  • バンドルアナライザで分析

6. メタデータ

静的 vs 動的

タイプ用途
静的export固定メタデータ
generateMetadataルートごとに動的

必須タグ

  • title (50-60文字)
  • description (150-160文字)
  • Open Graph画像
  • Canonical URL

7. キャッシュ戦略

キャッシュレイヤー

レイヤー制御
リクエストfetchオプション
データrevalidate/tags
フルルートroute設定

再検証

方法用途
時間ベースrevalidate: 60
オンデマンドrevalidatePath/Tag
キャッシュなしno-store

8. サーバーアクション

ユースケース

  • フォーム送信
  • データ変更
  • 再検証トリガー

ベストプラクティス

  • 'use server' でマーク
  • すべての入力をバリデーション
  • 型付きレスポンスを返す
  • エラーを処理

9. アンチパターン

❌ やらないこと✅ やるべきこと
すべてで 'use client'デフォルトでサーバー
クライアントコンポーネントでフェッチサーバーでフェッチ
ローディング状態をスキップloading.tsx を使用
エラーバウンダリを無視error.tsx を使用
大きなクライアントバンドル動的インポート

10. プロジェクト構造

app/
├── (marketing)/     # ルートグループ
│   └── page.tsx
├── (dashboard)/
│   ├── layout.tsx   # ダッシュボードレイアウト
│   └── page.tsx
├── api/
│   └── [resource]/
│       └── route.ts
└── components/
    └── ui/

覚えておいてください: サーバーコンポーネントには理由があってデフォルトです。まずはサーバーコンポーネントから始め、必要な場合にのみクライアントコンポーネントを追加しましょう。

Individual skills in this repo

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

marnixGeerkens/rocketlauncher-claude-code

When the user wants to optimize, improve, or increase conversions on any marketing page — including homepage, landing pages, pricing pages, feature pages, or blog posts. Also use when the user says "CRO," "conversion rate optimization," "this page isn't converting," "improve conversions," or "why isn't this page working." For signup/registration flows, see signup-flow-cro. For post-signup activation, see onboarding-cro. For forms outside of signup, see form-cro. For popups/modals, see popup-cro.

marnixGeerkens/rocketlauncher-claude-code

Balance visual design with ATS compatibility for creative roles. Use when the user is in design, art, writing, marketing creative, or any visual/creative field and needs a resume that looks distinctive but still parses.

marnixGeerkens/rocketlauncher-claude-code

Transform resume bullets into detailed portfolio case studies with context, action, and outcome. Use when the user mentions portfolio, case study, project write-up, or expanding a resume bullet into a longer narrative.

marnixGeerkens/rocketlauncher-claude-code

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities. Use when: portfolio, personal website, showcase work, developer portfolio, designer portfolio.

marnixGeerkens/rocketlauncher-claude-code

Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.

marnixGeerkens/rocketlauncher-claude-code

Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.

marnixGeerkens/rocketlauncher-claude-code

Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.

marnixGeerkens/rocketlauncher-claude-code

Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

marnixGeerkens/rocketlauncher-claude-code

Create API handoff documentation for frontend developers. Use when backend work is complete and needs to be documented for frontend integration, or user says 'create handoff', 'document API', 'frontend handoff', or 'API documentation'.

marnixGeerkens/rocketlauncher-claude-code

Document frontend data needs for backend developers. Use when frontend needs to communicate API requirements to backend, or user says 'backend requirements', 'what data do I need', 'API requirements', or is describing data needs for a UI.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

関連スキル