本文へ移動
cccskills
無料GitHub で公開

nextjs-app-router

Use this skill when creating routes, pages, layouts, or deciding Server vs Client Component boundaries in Next.js 16 App Router. Trigger words: ルーティング, ページ追加, layout, route, app router, Server Component, use client, dynamic route, generateMetadata.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Next.js 16 App Router

いつ使うか

  • 新しいページ・ルート・レイアウトを追加するとき。
  • Server Component と Client Component の境界をどこに引くか迷ったとき。
  • メタデータ(title / OG)や動的ルート([id])を設定するとき。

やること

  • app/ 配下にルートを置く。フォルダ = URL セグメント、page.tsx が画面、layout.tsx が共有レイアウト。
  • デフォルトは Server Component。データ取得は Server 側で await する。
  • インタラクティブ要素(state / イベント / ブラウザ API)だけを 'use client' の小さな葉に切り出す。
  • 各ルートに generateMetadata を置き、title と OpenGraph を設定する。
  • 動的ルートは params を受け取り、必要なら generateStaticParams で SSG する。

守るルール

  • ✅ Server Component デフォルト。'use client' は必要箇所のみ、できるだけ末端へ。
  • ✅ 画像は next/image、フォントは next/font。
  • ✅ generateMetadata で title / OG を必須設定。
  • ❌ Edge Runtime で Node 専用 API を使わない。
  • ❌ revalidate と cache: 'no-store' を同時指定しない。
  • ❌ export default を避け…られない場合だけ page/layout の規約に従う(Next.js は page をデフォルト export 必須とするため、ここは例外。それ以外のモジュールは named export)。

典型例(コード片)

// app/users/[id]/page.tsx — Server Component(デフォルト)
import type { Metadata } from 'next';
import { getUser } from '@/lib/users';

export async function generateMetadata(
  { params }: { params: Promise<{ id: string }> },
): Promise<Metadata> {
  const { id } = await params;
  const user = await getUser(id);
  return { title: `${user.name} さんのプロフィール`, openGraph: { title: user.name } };
}

export default async function UserPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const user = await getUser(id);
  return <UserProfile user={user} />; // インタラクティブ部分だけ別の 'use client' へ
}

アンチパターン

  • ページ全体に 'use client' を付けてサーバー取得の利点を捨てる。
  • params を同期アクセスする(Next.js 16 では params/searchParams は Promise)。
  • 動的データなのに静的化して古い内容を配信する(キャッシュ戦略を明示する)。

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

api-routes-hardening

無料日本語概要

Use this skill when creating or reviewing Next.js Route Handlers (app/api), adding rate limiting, input validation, or auth to API endpoints. Trigger words: API ルート, Route Handler, app/api, エンドポイント, レート制限, 入力検証, CORS, ヘッダー, 認証付き API, hardening.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

atlas-search-vector

無料日本語概要

Use this skill when implementing full-text search, autocomplete, or vector/semantic search and RAG with MongoDB Atlas. Trigger words: 全文検索, あいまい検索, オートコンプリート, ベクトル検索, セマンティック検索, 類似検索, Atlas Search, $search, $vectorSearch, RAG, embedding.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

auth-better-auth

無料日本語概要

Use this skill when implementing sign-in, sessions, authorization checks, or protecting routes and Server Actions. Trigger words: 認証, ログイン, サインイン, セッション, 認可, 権限チェック, Better Auth, Auth.js, 保護, ミドルウェア, getSession.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

bootstrap

無料日本語概要

Use this skill when starting a new session, opening this project for the first time, or when you need to recall the project's tech stack, hard rules, and which other skills exist. Trigger words: セッション開始, このプロジェクト, 全体像, どのスキル, 何から, getting started, overview.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

ci-github-actions

無料日本語概要

Use this skill when setting up or modifying CI pipelines, GitHub Actions workflows, or automated checks (lint, typecheck, test, build) for this project. Trigger words: CI, GitHub Actions, ワークフロー, パイプライン, 自動テスト, lint チェック, typecheck, ビルド検証, .github/workflows.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

e2e-playwright

無料日本語概要

Use this skill when writing end-to-end tests, browser automation, or verifying user flows in a real browser. Trigger words: E2E, Playwright, ブラウザテスト, ユーザーフロー, 結合テスト, シナリオテスト, ログインテスト, getByRole, expect.

Akira-Papa/claude-code-nextjs-mongo-template-162026年5月24日 更新

Akira-Papa のスキルをすべて見る

このスキルの問題を報告する