jpskill.com
🛠️ 開発・MCP コミュニティ

nextjs-15-specialist

Use when working with Next.js 15 features, App Router, Server Components, Server Actions, or data fetching patterns. Ensures correct usage of Server vs Client Components and modern Next.js patterns.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o nextjs-15-specialist.zip https://jpskill.com/download/17462.zip && unzip -o nextjs-15-specialist.zip && rm nextjs-15-specialist.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17462.zip -OutFile "$d\nextjs-15-specialist.zip"; Expand-Archive "$d\nextjs-15-specialist.zip" -DestinationPath $d -Force; ri "$d\nextjs-15-specialist.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して nextjs-15-specialist.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → nextjs-15-specialist フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Next.js 15 + App Router スペシャリスト

Quetrex 開発のための完全な Next.js 15 リファレンス。

このスキルは、すべての Next.js 15 App Router パターンに関する包括的なガイダンスを提供し、エージェントが最新の Next.js を最初に正しく実装できるようにします。


重要なルール (絶対に違反しないこと)

これらのルールは交渉の余地がありません。違反するとビルドが中断されます。

1. 常に next/image<Image> を使用する - <img> は絶対に使用しない

// ✅ 常にこれを行う
import Image from 'next/image'

<Image src="/logo.png" alt="Logo" width={200} height={100} />
<Image src={user.avatar} alt={user.name} width={40} height={40} />

// ❌ 絶対にこれを行わない - ビルドが失敗する
<img src="/logo.png" alt="Logo" />
<img src={user.avatar} alt={user.name} />

理由: Next.js の Image コンポーネントは、自動最適化、遅延ロードを提供し、レイアウトシフトを防ぎます。 ESLint は、<img> の使用時にビルドが失敗するように構成されています。

2. サーバーコンポーネントがデフォルト - 必要な場合にのみ 'use client' を追加する

3. 非同期のクライアントコンポーネントは絶対に作成しない

4. 常に fetch() のキャッシュ戦略を指定する


このスキルを使用するタイミング

このスキルは、以下を扱う際に使用します。

  • 新しいルートまたはページの作成
  • データフェッチの実装 (サーバーコンポーネント vs クライアントコンポーネント)
  • サーバー vs クライアントコンポーネントの決定
  • サーバーアクションとフォーム処理
  • ストリーミングと Suspense
  • メタデータと SEO
  • ルートハンドラー (API ルート)
  • キャッシュ戦略
  • パフォーマンス最適化

完全なドキュメント

このスキルには、すべての Next.js 15 パターンを網羅した包括的なガイドが含まれています。

📁 App Router 完全ガイド

45 以上の例を網羅:

  • ファイルベースルーティング (page.tsx, layout.tsx, route.ts)
  • 動的ルート ([id], [...slug], [[...slug]])
  • ルートグループ ((group))
  • プライベートフォルダ (_folder)
  • ルートハンドラー (API ルート)
  • レイアウトとテンプレート
  • ローディング UI (loading.tsx)
  • エラー境界 (error.tsx, global-error.tsx)
  • Not found ページ (not-found.tsx)
  • パラレルルート (@folder)
  • インターセプトルート ((.)folder)
  • ルートセグメント設定 (dynamic, revalidate, runtime)

🔄 データフェッチ完全ガイド

35 以上の例を網羅:

  • サーバーコンポーネントのデータフェッチ (async/await)
  • クライアントコンポーネントのデータフェッチ (useEffect, React Query, SWR)
  • パラレルデータフェッチ (Promise.all)
  • シーケンシャルデータフェッチ (ウォーターフォール防止)
  • ストリーミングデータ (Suspense 境界)
  • Server-Sent Events (Quetrex voice 用の SSE)
  • データミューテーション (サーバーアクション)
  • 楽観的アップデート (useOptimistic)
  • フォーム処理 (useFormStatus, useActionState)
  • リクエストの重複排除
  • データのプリロード

💾 キャッシュ戦略ガイド

35 以上の例を網羅:

  • リクエストのメモ化 (自動重複排除)
  • データキャッシュ (fetch キャッシュの動作)
  • フルルートキャッシュ (static vs dynamic)
  • ルーターキャッシュ (クライアントサイドキャッシュ)
  • キャッシュ設定 (force-cache, no-store, revalidate)
  • キャッシュタグ (revalidateTag, revalidatePath)
  • オンデマンド再検証
  • 時間ベースの再検証 (ISR)
  • キャッシュデバッグテクニック
  • キャッシュのオプトアウト

サーバーアクション完全ガイド

31 以上の例を網羅:

  • 基本的なサーバーアクションパターン
  • フォームアクション (プログレッシブエンハンスメント)
  • ボタンアクション (プログラムによる呼び出し)
  • useFormStatus フック (ローディング状態)
  • useActionState フック (状態管理)
  • useOptimistic フック (楽観的 UI)
  • アクションのエラー処理
  • Zod によるバリデーション
  • JSON の返却 vs リダイレクト
  • セキュリティ (認証、CSRF)
  • レート制限
  • データベーストランザクション

🎯 Metadata API ガイド

26 以上の例を網羅:

  • 静的メタデータ (エクスポートされたオブジェクト)
  • 動的メタデータ (generateMetadata)
  • ファイルベースのメタデータ (icon.png, opengraph-image.png)
  • Open Graph メタデータ
  • Twitter Cards
  • JSON-LD 構造化データ
  • ビューポート設定
  • PWA マニフェスト
  • Robots.txt
  • サイトマップ生成

パターンバリデーター

以下をチェックする実行可能な Python スクリプト:

  • サーバーコンポーネントがクライアント専用の API を使用していないか
  • クライアントコンポーネントに 'use client' ディレクティブがあるか
  • データフェッチが適切なキャッシュ戦略を使用しているか
  • サーバーアクションが 'use server' でマークされているか
  • Metadata API が正しく使用されているか
  • 画像最適化 (<Image><img> ではないか)
  • 重いコンポーネントの動的インポート

実行方法: python validate-patterns.py /path/to/src


クイックリファレンス

サーバー vs クライアントコンポーネントの決定木

インタラクティビティ (onClick, onChange など) が必要ですか?
├─ YES → クライアントコンポーネント ('use client')
└─ NO → サーバーコンポーネント (デフォルト)

React フック (useState, useEffect) が必要ですか?
├─ YES → クライアントコンポーネント
└─ NO → サーバーコンポーネント

ブラウザ API (window, localStorage) が必要ですか?
├─ YES → クライアントコンポーネント
└─ NO → サーバーコンポーネント

データをフェッチする必要がありますか?
├─ サーバーコンポーネントを使用 (推奨)
└─ データがクライアントサイドにある必要がある場合にのみクライアントコンポーネントを使用

コンポーネントは純粋にプレゼンテーション用ですか?
└─ サーバーコンポーネント (パフォーマンスが向上)

一般的なパターン

1. サーバーコンポーネントのデータフェッチ

// app/projects/page.tsx
export default async function ProjectsPage() {
  const projects = await db.project.findMany()
  return <ProjectList projects={projects} />
}

2. インタラクティビティを備えたクライアントコンポーネント

// components/ProjectCard.tsx
'use client'

import { useState } from 'react'

export function ProjectCard({ project }: Props) {
  const [loading, setLoading] = useState(false)

  const handleDelete = async () => {
    setLoading(true)
    await deleteProject(project.id)
    setLoading(false)
  }

  return (
    <div>
      <h2>{project.name}</h2>
      <button onClick={handleDelete} disabled={loading}>
        Delete
      </button>
    </div>
  )
}

3. フォームを使用したサーバーアクション

// app/actions.ts
'use server'

export async function createProject(formData: FormData) {
  const name = formData.get('name') as string
  const project = await db.project.create({ data: { name } })
  revalidatePath('/projects')
  return { success: true, project }
}
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Next.js 15 + App Router Specialist

Complete Next.js 15 reference for Quetrex development.

This skill provides comprehensive guidance on all Next.js 15 App Router patterns, ensuring agents implement modern Next.js correctly the first time.


CRITICAL RULES (NEVER VIOLATE)

These rules are NON-NEGOTIABLE. Violations will break builds.

1. ALWAYS use <Image> from next/image - NEVER use <img>

// ✅ ALWAYS DO THIS
import Image from 'next/image'

<Image src="/logo.png" alt="Logo" width={200} height={100} />
<Image src={user.avatar} alt={user.name} width={40} height={40} />

// ❌ NEVER DO THIS - BUILD WILL FAIL
<img src="/logo.png" alt="Logo" />
<img src={user.avatar} alt={user.name} />

Why: Next.js Image component provides automatic optimization, lazy loading, and prevents layout shift. ESLint is configured to fail builds on <img> usage.

2. Server Components are DEFAULT - only add 'use client' when needed

3. Never make async Client Components

4. Always specify cache strategy for fetch()


When to Use This Skill

Use this skill when working with:

  • Creating new routes or pages
  • Implementing data fetching (Server Components vs Client Components)
  • Server vs Client Component decisions
  • Server Actions and form handling
  • Streaming and Suspense
  • Metadata and SEO
  • Route handlers (API routes)
  • Caching strategies
  • Performance optimization

Complete Documentation

This skill includes comprehensive guides covering every Next.js 15 pattern:

📁 App Router Complete Guide

45+ examples covering:

  • File-based routing (page.tsx, layout.tsx, route.ts)
  • Dynamic routes ([id], [...slug], [[...slug]])
  • Route groups ((group))
  • Private folders (_folder)
  • Route handlers (API routes)
  • Layouts and templates
  • Loading UI (loading.tsx)
  • Error boundaries (error.tsx, global-error.tsx)
  • Not found pages (not-found.tsx)
  • Parallel routes (@folder)
  • Intercepting routes ((.)folder)
  • Route segment config (dynamic, revalidate, runtime)

🔄 Data Fetching Complete Guide

35+ examples covering:

  • Server Component data fetching (async/await)
  • Client Component data fetching (useEffect, React Query, SWR)
  • Parallel data fetching (Promise.all)
  • Sequential data fetching (waterfall prevention)
  • Streaming data (Suspense boundaries)
  • Server-Sent Events (SSE for Quetrex voice)
  • Data mutations (Server Actions)
  • Optimistic updates (useOptimistic)
  • Form handling (useFormStatus, useActionState)
  • Request deduplication
  • Preloading data

💾 Caching Strategies Guide

35+ examples covering:

  • Request memoization (automatic deduplication)
  • Data Cache (fetch cache behavior)
  • Full Route Cache (static vs dynamic)
  • Router Cache (client-side cache)
  • Cache configuration (force-cache, no-store, revalidate)
  • Cache tags (revalidateTag, revalidatePath)
  • On-demand revalidation
  • Time-based revalidation (ISR)
  • Cache debugging techniques
  • Opting out of caching

Server Actions Complete Guide

31+ examples covering:

  • Basic Server Action patterns
  • Form actions (progressive enhancement)
  • Button actions (programmatic calls)
  • useFormStatus hook (loading states)
  • useActionState hook (state management)
  • useOptimistic hook (optimistic UI)
  • Error handling in actions
  • Validation with Zod
  • Returning JSON vs redirect
  • Security (authentication, CSRF)
  • Rate limiting
  • Database transactions

🎯 Metadata API Guide

26+ examples covering:

  • Static metadata (exported object)
  • Dynamic metadata (generateMetadata)
  • File-based metadata (icon.png, opengraph-image.png)
  • Open Graph metadata
  • Twitter Cards
  • JSON-LD structured data
  • Viewport configuration
  • PWA manifest
  • Robots.txt
  • Sitemap generation

Pattern Validator

Executable Python script that checks:

  • Server Components don't use client-only APIs
  • Client Components have 'use client' directive
  • Data fetching uses proper cache strategy
  • Server Actions are marked with 'use server'
  • Metadata API used correctly
  • Image optimization (<Image> not <img>)
  • Dynamic imports for heavy components

Run with: python validate-patterns.py /path/to/src


Quick Reference

Server vs Client Components Decision Tree

Do you need interactivity (onClick, onChange, etc.)?
├─ YES → Client Component ('use client')
└─ NO → Server Component (default)

Do you need React hooks (useState, useEffect)?
├─ YES → Client Component
└─ NO → Server Component

Do you need browser APIs (window, localStorage)?
├─ YES → Client Component
└─ NO → Server Component

Do you need to fetch data?
├─ Use Server Component (preferred)
└─ Only use Client Component if data must be client-side

Is the component purely presentational?
└─ Server Component (better performance)

Common Patterns

1. Server Component Data Fetching

// app/projects/page.tsx
export default async function ProjectsPage() {
  const projects = await db.project.findMany()
  return <ProjectList projects={projects} />
}

2. Client Component with Interactivity

// components/ProjectCard.tsx
'use client'

import { useState } from 'react'

export function ProjectCard({ project }: Props) {
  const [loading, setLoading] = useState(false)

  const handleDelete = async () => {
    setLoading(true)
    await deleteProject(project.id)
    setLoading(false)
  }

  return (
    <div>
      <h2>{project.name}</h2>
      <button onClick={handleDelete} disabled={loading}>
        Delete
      </button>
    </div>
  )
}

3. Server Action with Form

// app/actions.ts
'use server'

export async function createProject(formData: FormData) {
  const name = formData.get('name') as string
  const project = await db.project.create({ data: { name } })
  revalidatePath('/projects')
  return { success: true, project }
}

// app/projects/new/page.tsx
import { createProject } from '@/app/actions'

export default function NewProjectPage() {
  return (
    <form action={createProject}>
      <input name="name" required />
      <button type="submit">Create</button>
    </form>
  )
}

4. Streaming with Suspense

// app/dashboard/page.tsx
import { Suspense } from 'react'

export default function DashboardPage() {
  return (
    <div>
      <Suspense fallback={<ProjectsSkeleton />}>
        <ProjectsAsync />
      </Suspense>
      <Suspense fallback={<UsersSkeleton />}>
        <UsersAsync />
      </Suspense>
    </div>
  )
}

async function ProjectsAsync() {
  const projects = await fetchProjects() // Slow query
  return <ProjectList projects={projects} />
}

5. Dynamic Metadata

// app/blog/[slug]/page.tsx
import type { Metadata } from 'next'

export async function generateMetadata({
  params,
}: {
  params: Promise<{ slug: string }>
}): Promise<Metadata> {
  const { slug } = await params
  const post = await fetchPost(slug)

  return {
    title: post.title,
    description: post.excerpt,
    openGraph: {
      title: post.title,
      description: post.excerpt,
      images: [post.coverImage],
    },
  }
}

Best Practices for Quetrex

1. Default to Server Components

// ✅ DO: Server Component (default)
export default async function ProjectsPage() {
  const projects = await fetchProjects()
  return <ProjectList projects={projects} />
}

// ❌ DON'T: Client Component when not needed
'use client'
export default function ProjectsPage() {
  const [projects, setProjects] = useState([])
  useEffect(() => {
    fetchProjects().then(setProjects)
  }, [])
  return <ProjectList projects={projects} />
}

2. Use Proper Cache Strategy

// Static content (cached forever)
const categories = await fetch('https://api.example.com/categories', {
  cache: 'force-cache',
}).then(r => r.json())

// Dynamic content (no cache)
const user = await fetch('https://api.example.com/me', {
  cache: 'no-store',
}).then(r => r.json())

// ISR (revalidate every hour)
const products = await fetch('https://api.example.com/products', {
  next: { revalidate: 3600 },
}).then(r => r.json())

3. Implement Proper Error Boundaries

// app/dashboard/error.tsx
'use client'

export default function DashboardError({
  error,
  reset,
}: {
  error: Error
  reset: () => void
}) {
  return (
    <div>
      <h2>Something went wrong!</h2>
      <button onClick={reset}>Try again</button>
    </div>
  )
}

4. Use Loading States

// app/dashboard/loading.tsx
export default function DashboardLoading() {
  return <DashboardSkeleton />
}

5. Optimize Images

// ✅ DO: Use next/image
import Image from 'next/image'

export function ProjectCard({ project }) {
  return (
    <Image
      src={project.image}
      alt={project.name}
      width={400}
      height={300}
    />
  )
}

// ❌ DON'T: Use <img> tag
export function ProjectCard({ project }) {
  return <img src={project.image} alt={project.name} />
}

Common Mistakes to Avoid

❌ Mistake 1: Async Client Component

// ❌ DON'T: This is a syntax error
'use client'

export default async function BadComponent() {
  const data = await fetch('/api/data')
  return <div>{data}</div>
}

// ✅ DO: Use Server Component or useEffect
export default async function GoodComponent() {
  const data = await fetch('/api/data')
  return <div>{data}</div>
}

❌ Mistake 2: Client APIs in Server Component

// ❌ DON'T: Server Components can't use browser APIs
export default function BadComponent() {
  const [state, setState] = useState(false) // Error!
  return <div>{state}</div>
}

// ✅ DO: Add 'use client' directive
'use client'

export default function GoodComponent() {
  const [state, setState] = useState(false)
  return <div>{state}</div>
}

❌ Mistake 3: Missing Cache Strategy

// ❌ DON'T: Unclear caching behavior
const data = await fetch('/api/data')

// ✅ DO: Explicit cache strategy
const data = await fetch('/api/data', {
  cache: 'no-store', // or 'force-cache', or { next: { revalidate: 60 } }
})

❌ Mistake 4: Not Using <Image>

// ❌ DON'T: Unoptimized images
<img src="/logo.png" alt="Logo" />

// ✅ DO: Use Next.js Image optimization
<Image src="/logo.png" alt="Logo" width={200} height={100} />

Troubleshooting

Error: "You're importing a component that needs useState..."

Solution: Add 'use client' to the component file.

Error: "async/await is not valid in Client Components"

Solution: Remove 'use client' or use useEffect instead of async component.

Error: "process is not defined"

Solution: Environment variables in Client Components need NEXT_PUBLIC_ prefix.

Error: "Headers already sent"

Solution: Don't use headers() or cookies() after sending response. Call them before any streaming.


Official Documentation


Validation

Run the pattern validator to check your code:

python .claude/skills/nextjs-15-specialist/validate-patterns.py src/

The validator checks for:

  • ✅ Async Client Components (forbidden)
  • ✅ Client APIs in Server Components
  • ✅ 'use client' directive placement
  • ✅ Server Action async functions
  • ✅ Image optimization
  • ✅ Metadata in dynamic routes
  • ✅ Dynamic imports for heavy components
  • ✅ Fetch cache strategies
  • ✅ Route segment config

Summary

This skill ensures you:

  1. Choose correct component type (Server vs Client)
  2. Implement proper data fetching patterns
  3. Use appropriate caching strategies
  4. Handle Server Actions correctly
  5. Optimize metadata and SEO
  6. Avoid common Next.js mistakes
  7. Follow Quetrex's architecture guidelines

When in doubt:

  • Read the specific guide (links above)
  • Run the validator
  • Check official Next.js 15 docs
  • Default to Server Components

Last updated: 2025-11-23 Next.js Version: 15.5 Total Examples: 150+ Total Lines: 4,000+