building-nextjs-apps
Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o building-nextjs-apps.zip https://jpskill.com/download/17288.zip && unzip -o building-nextjs-apps.zip && rm building-nextjs-apps.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17288.zip -OutFile "$d\building-nextjs-apps.zip"; Expand-Archive "$d\building-nextjs-apps.zip" -DestinationPath $d -Force; ri "$d\building-nextjs-apps.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
building-nextjs-apps.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
building-nextjs-appsフォルダができる - 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
- 同梱ファイル
- 5
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Next.js 16 アプリケーション
特徴的なデザインで、正しく Next.js 16 アプリケーションを構築します。
重大な破壊的変更 (Next.js 16)
1. params と searchParams が Promise に
これは最もよくある間違いです。
// 間違い - Next.js 15 のパターン (失敗します)
export default function Page({ params }: { params: { id: string } }) {
return <div>ID: {params.id}</div>
}
// 正しい - Next.js 16 のパターン
export default async function Page({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
return <div>ID: {id}</div>
}
2. Client Components には use() Hook が必要
"use client"
import { use } from "react"
export default function ClientPage({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = use(params)
return <div>ID: {id}</div>
}
3. searchParams も非同期
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ page?: string }>
}) {
const { page } = await searchParams
return <div>Page: {page ?? "1"}</div>
}
コアパターン
プロジェクトのセットアップ
npx create-next-app@latest my-app --typescript --tailwind --eslint
cd my-app
# shadcn/ui を追加
npx shadcn@latest init
npx shadcn@latest add button form dialog table sidebar
App Router Layout
// app/layout.tsx
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className="min-h-screen">
{children}
</body>
</html>
)
}
Dynamic Routes
// app/tasks/[id]/page.tsx
export default async function TaskPage({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
const task = await getTask(id)
return (
<main>
<h1>{task.title}</h1>
</main>
)
}
Server Actions
// app/actions.ts
"use server"
import { revalidatePath } from "next/cache"
export async function createTask(formData: FormData) {
const title = formData.get("title") as string
await db.insert(tasks).values({ title })
revalidatePath("/tasks")
}
// コンポーネントでの使用例
<form action={createTask}>
<input name="title" />
<button type="submit">Create</button>
</form>
API Routes
// app/api/tasks/route.ts
import { NextResponse } from "next/server"
export async function GET() {
const tasks = await db.select().from(tasksTable)
return NextResponse.json(tasks)
}
export async function POST(request: Request) {
const body = await request.json()
const task = await db.insert(tasksTable).values(body).returning()
return NextResponse.json(task, { status: 201 })
}
Middleware → proxy.ts
// proxy.ts (Next.js 16 での middleware.ts の代替)
import { NextRequest } from "next/server"
export function proxy(request: NextRequest) {
// 認証チェック
const token = request.cookies.get("token")
if (!token && request.nextUrl.pathname.startsWith("/dashboard")) {
return Response.redirect(new URL("/login", request.url))
}
}
export const config = {
matcher: ["/dashboard/:path*"],
}
Data Fetching
Server Component (デフォルト)
// これはサーバー上で実行されます - async/await を直接使用できます
async function TaskList() {
const tasks = await fetch("https://api.example.com/tasks", {
cache: "no-store", // SSR, または
// next: { revalidate: 60 } // ISR
}).then(r => r.json())
return (
<ul>
{tasks.map(task => <li key={task.id}>{task.title}</li>)}
</ul>
)
}
Client Component
"use client"
import useSWR from "swr"
const fetcher = (url: string) => fetch(url).then(r => r.json())
export function ClientTaskList() {
const { data, error, isLoading } = useSWR("/api/tasks", fetcher)
if (isLoading) return <div>Loading...</div>
if (error) return <div>Error loading tasks</div>
return (
<ul>
{data.map(task => <li key={task.id}>{task.title}</li>)}
</ul>
)
}
プロジェクト構成
app/
├── layout.tsx # ルートレイアウト
├── page.tsx # ホームページ
├── globals.css # グローバルスタイル
├── api/ # API ルート
│ └── tasks/route.ts
├── tasks/
│ ├── page.tsx # /tasks
│ └── [id]/page.tsx # /tasks/:id
├── actions.ts # サーバーアクション
└── proxy.ts # リクエストプロキシ (ミドルウェア)
components/
├── ui/ # shadcn/ui コンポーネント
└── task-list.tsx # アプリコンポーネント
lib/
├── db.ts # データベース接続
└── utils.ts # ユーティリティ
Next.js DevTools MCP
ランタイム診断と開発自動化のために、next-devtools-mcp サーバーを使用します。
セットアップ
claude mcp add next-devtools npx next-devtools-mcp@latest
または settings.json で:
{
"mcpServers": {
"next-devtools": {
"type": "stdio",
"command": "npx",
"args": ["next-devtools-mcp@latest"]
}
}
}
利用可能なツール
| Tool | Purpose |
|---|---|
init |
利用可能なツールとベストプラクティスでコンテキストを確立します |
nextjs_docs |
公式 Next.js ドキュメントを検索して取得します |
browser_eval |
Playwright でブラウザテストを自動化します |
nextjs_index |
実行中の Next.js 開発サーバーを検出します |
nextjs_call |
実行中の開発サーバーで MCP ツールを実行します |
upgrade_nextjs_16 |
コードモッドによる自動アップグレード |
enable_cache_components |
Next.js 16 の Cache Components を構成します |
主なユースケース
1. リアルタイムのエラーを取得
"私の Next.js アプリにはどのようなビルドエラーがありますか?"
"現在のプロジェクトの TypeScript エラーを表示してください"
2. ランタイムの問題をデバッグ
"開発サーバーを確認してください
(原文はここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Next.js 16 Applications
Build Next.js 16 applications correctly with distinctive design.
Critical Breaking Changes (Next.js 16)
1. params and searchParams are Now Promises
THIS IS THE MOST COMMON MISTAKE.
// WRONG - Next.js 15 pattern (WILL FAIL)
export default function Page({ params }: { params: { id: string } }) {
return <div>ID: {params.id}</div>
}
// CORRECT - Next.js 16 pattern
export default async function Page({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
return <div>ID: {id}</div>
}
2. Client Components Need use() Hook
"use client"
import { use } from "react"
export default function ClientPage({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = use(params)
return <div>ID: {id}</div>
}
3. searchParams Also Async
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ page?: string }>
}) {
const { page } = await searchParams
return <div>Page: {page ?? "1"}</div>
}
Core Patterns
Project Setup
npx create-next-app@latest my-app --typescript --tailwind --eslint
cd my-app
# Add shadcn/ui
npx shadcn@latest init
npx shadcn@latest add button form dialog table sidebar
App Router Layout
// app/layout.tsx
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className="min-h-screen">
{children}
</body>
</html>
)
}
Dynamic Routes
// app/tasks/[id]/page.tsx
export default async function TaskPage({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
const task = await getTask(id)
return (
<main>
<h1>{task.title}</h1>
</main>
)
}
Server Actions
// app/actions.ts
"use server"
import { revalidatePath } from "next/cache"
export async function createTask(formData: FormData) {
const title = formData.get("title") as string
await db.insert(tasks).values({ title })
revalidatePath("/tasks")
}
// Usage in component
<form action={createTask}>
<input name="title" />
<button type="submit">Create</button>
</form>
API Routes
// app/api/tasks/route.ts
import { NextResponse } from "next/server"
export async function GET() {
const tasks = await db.select().from(tasksTable)
return NextResponse.json(tasks)
}
export async function POST(request: Request) {
const body = await request.json()
const task = await db.insert(tasksTable).values(body).returning()
return NextResponse.json(task, { status: 201 })
}
Middleware → proxy.ts
// proxy.ts (replaces middleware.ts in Next.js 16)
import { NextRequest } from "next/server"
export function proxy(request: NextRequest) {
// Authentication check
const token = request.cookies.get("token")
if (!token && request.nextUrl.pathname.startsWith("/dashboard")) {
return Response.redirect(new URL("/login", request.url))
}
}
export const config = {
matcher: ["/dashboard/:path*"],
}
Data Fetching
Server Component (Default)
// This runs on the server - can use async/await directly
async function TaskList() {
const tasks = await fetch("https://api.example.com/tasks", {
cache: "no-store", // SSR, or
// next: { revalidate: 60 } // ISR
}).then(r => r.json())
return (
<ul>
{tasks.map(task => <li key={task.id}>{task.title}</li>)}
</ul>
)
}
Client Component
"use client"
import useSWR from "swr"
const fetcher = (url: string) => fetch(url).then(r => r.json())
export function ClientTaskList() {
const { data, error, isLoading } = useSWR("/api/tasks", fetcher)
if (isLoading) return <div>Loading...</div>
if (error) return <div>Error loading tasks</div>
return (
<ul>
{data.map(task => <li key={task.id}>{task.title}</li>)}
</ul>
)
}
Project Structure
app/
├── layout.tsx # Root layout
├── page.tsx # Home page
├── globals.css # Global styles
├── api/ # API routes
│ └── tasks/route.ts
├── tasks/
│ ├── page.tsx # /tasks
│ └── [id]/page.tsx # /tasks/:id
├── actions.ts # Server actions
└── proxy.ts # Request proxy (middleware)
components/
├── ui/ # shadcn/ui components
└── task-list.tsx # App components
lib/
├── db.ts # Database connection
└── utils.ts # Utilities
Next.js DevTools MCP
Use the next-devtools-mcp server for runtime diagnostics and development automation.
Setup
claude mcp add next-devtools npx next-devtools-mcp@latest
Or in settings.json:
{
"mcpServers": {
"next-devtools": {
"type": "stdio",
"command": "npx",
"args": ["next-devtools-mcp@latest"]
}
}
}
Available Tools
| Tool | Purpose |
|---|---|
init |
Establish context with available tools and best practices |
nextjs_docs |
Search and fetch official Next.js documentation |
browser_eval |
Automate browser testing with Playwright |
nextjs_index |
Discover running Next.js dev servers |
nextjs_call |
Execute MCP tools on running dev servers |
upgrade_nextjs_16 |
Automated upgrade with codemods |
enable_cache_components |
Configure Cache Components for Next.js 16 |
Key Use Cases
1. Get Real-time Errors
"What build errors are there in my Next.js app?"
"Show me TypeScript errors in the current project"
2. Debug Runtime Issues
"Check the dev server logs for errors"
"What runtime errors are happening on the dashboard page?"
3. Upgrade Assistance
"Upgrade this project to Next.js 16"
"Enable cache components for this app"
4. Documentation Lookup
"How do I use the Image component in Next.js 16?"
"What's the correct way to handle dynamic routes?"
Next.js 16 MCP Endpoint
Next.js 16+ exposes a built-in MCP endpoint at http://localhost:3000/_next/mcp (or your dev server port). The devtools MCP automatically discovers and connects to running servers.
Verification
Run: python3 scripts/verify.py
Expected: ✓ building-nextjs-apps skill ready
If Verification Fails
- Check: references/ folder has nextjs-16-patterns.md
- Stop and report if still failing
Related Skills
- styling-with-shadcn - UI components for Next.js apps
- fetching-library-docs - Latest Next.js docs:
--library-id /vercel/next.js --topic routing - configuring-better-auth - OAuth/SSO for Next.js apps
References
- references/nextjs-16-patterns.md - Complete Next.js 16 patterns
- references/frontend-design.md - Aesthetic guidelines for distinctive UI
- references/datetime-patterns.md - UTC/timezone handling for datetime-local inputs
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (7,898 bytes)
- 📎 references/datetime-patterns.md (5,175 bytes)
- 📎 references/frontend-design.md (2,023 bytes)
- 📎 references/nextjs-16-patterns.md (17,482 bytes)
- 📎 scripts/verify.py (613 bytes)