_legacy/frontend/nextjs-development/SKILL.md
Next.js App Router開発ガイド。Server Components、ルーティング、データフェッチング、キャッシング、デプロイなど、Next.js開発のベストプラクティス。
npx skillsauth add gaku52/claude-code-skills nextjs-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
このSkillは、Next.js App Router開発をカバーします:
このガイドで学べること: App Routerパターン、Server Components設計、キャッシング戦略 公式で確認すべきこと: 最新API、Next.js 15の新機能、デプロイオプション、マイグレーションガイド
Next.js Documentation - Next.js公式ドキュメント
Next.js Learn - 公式チュートリアル
プロダクションレベルの実装を学ぶには、以下の完全ガイドを参照してください:
23,000文字 | 完全なTypeScript実装例 | 実測値データ付き
28,000文字 | Prisma統合 | Server Actions実装
26,000文字 | 4つのキャッシュ階層 | Webhook連携
合計: 77,000文字 | 30以上の完全実装例 | 実プロジェクトの測定データ
app/
├── page.tsx # / (ルート)
├── about/page.tsx # /about
├── blog/
│ ├── page.tsx # /blog
│ └── [slug]/page.tsx # /blog/hello-world
├── dashboard/
│ ├── layout.tsx # /dashboard のレイアウト
│ ├── page.tsx # /dashboard
│ └── settings/page.tsx # /dashboard/settings
└── api/
└── users/route.ts # /api/users
// app/page.tsx(ルートページ)
export default function Home() {
return (
<main>
<h1>Welcome</h1>
</main>
)
}
// app/layout.tsx(ルートレイアウト)
export const metadata = {
title: 'My App',
description: 'App description',
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="ja">
<body>
<nav>ナビゲーション</nav>
{children}
<footer>フッター</footer>
</body>
</html>
)
}
// app/dashboard/layout.tsx(ネストレイアウト)
export default function DashboardLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div className="flex">
<aside>サイドバー</aside>
<main>{children}</main>
</div>
)
}
// app/blog/[slug]/page.tsx
interface PageProps {
params: { slug: string }
searchParams: { [key: string]: string | string[] | undefined }
}
export default function BlogPost({ params }: PageProps) {
return <h1>Post: {params.slug}</h1>
}
// 静的生成用
export async function generateStaticParams() {
const posts = await getPosts()
return posts.map((post) => ({
slug: post.slug,
}))
}
// app/posts/page.tsx
// ✅ Server Component(デフォルト)
async function getPosts() {
const res = await fetch('https://api.example.com/posts', {
next: { revalidate: 3600 } // 1時間キャッシュ
})
return res.json()
}
export default async function PostsPage() {
const posts = await getPosts() // 直接await可能
return (
<ul>
{posts.map(post => (
<li key={post.id}>{post.title}</li>
))}
</ul>
)
}
メリット:
// components/Counter.tsx
'use client' // ← 必須
import { useState } from 'react'
export function Counter() {
const [count, setCount] = useState(0)
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
)
}
使用するタイミング:
// app/page.tsx(Server Component)
import { Counter } from '@/components/Counter' // Client Component
async function getInitialCount() {
// サーバーでデータ取得
return 42
}
export default async function Home() {
const initialCount = await getInitialCount()
return (
<div>
<h1>Server Component</h1>
<Counter initialValue={initialCount} />
</div>
)
}
// キャッシュあり(デフォルト)
async function getData() {
const res = await fetch('https://api.example.com/data')
return res.json()
}
// キャッシュなし
async function getData() {
const res = await fetch('https://api.example.com/data', {
cache: 'no-store'
})
return res.json()
}
// 時間ベースリバリデーション
async function getData() {
const res = await fetch('https://api.example.com/data', {
next: { revalidate: 3600 } // 1時間
})
return res.json()
}
// lib/prisma.ts
import { PrismaClient } from '@prisma/client'
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined
}
export const prisma = globalForPrisma.prisma ?? new PrismaClient()
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
// app/users/page.tsx
import { prisma } from '@/lib/prisma'
export default async function UsersPage() {
const users = await prisma.user.findMany()
return (
<ul>
{users.map(user => (
<li key={user.id}>{user.name}</li>
))}
</ul>
)
}
// 60秒ごとに再検証
fetch('https://api.example.com/data', {
next: { revalidate: 60 }
})
// app/api/revalidate/route.ts
import { revalidatePath } from 'next/cache'
import { NextRequest } from 'next/server'
export async function POST(request: NextRequest) {
const path = request.nextUrl.searchParams.get('path')
if (path) {
revalidatePath(path)
return Response.json({ revalidated: true, now: Date.now() })
}
return Response.json({ revalidated: false })
}
// 使用例
// POST /api/revalidate?path=/posts
// app/blog/page.tsx
import Link from 'next/link'
async function getPosts() {
const res = await fetch('https://jsonplaceholder.typicode.com/posts', {
next: { revalidate: 3600 }
})
return res.json()
}
export default async function BlogPage() {
const posts = await getPosts()
return (
<div>
<h1>Blog</h1>
<ul>
{posts.map((post: any) => (
<li key={post.id}>
<Link href={`/blog/${post.id}`}>
{post.title}
</Link>
</li>
))}
</ul>
</div>
)
}
// app/blog/[id]/page.tsx
async function getPost(id: string) {
const res = await fetch(`https://jsonplaceholder.typicode.com/posts/${id}`, {
next: { revalidate: 3600 }
})
return res.json()
}
export default async function PostPage({ params }: { params: { id: string } }) {
const post = await getPost(params.id)
return (
<article>
<h1>{post.title}</h1>
<p>{post.body}</p>
</article>
)
}
// app/api/users/route.ts
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
// GET /api/users
export async function GET() {
const users = await prisma.user.findMany()
return NextResponse.json(users)
}
// POST /api/users
export async function POST(request: NextRequest) {
const body = await request.json()
const user = await prisma.user.create({
data: {
name: body.name,
email: body.email,
},
})
return NextResponse.json(user, { status: 201 })
}
// app/api/users/[id]/route.ts
// PUT /api/users/:id
export async function PUT(
request: NextRequest,
{ params }: { params: { id: string } }
) {
const body = await request.json()
const user = await prisma.user.update({
where: { id: params.id },
data: body,
})
return NextResponse.json(user)
}
// DELETE /api/users/:id
export async function DELETE(
request: NextRequest,
{ params }: { params: { id: string } }
) {
await prisma.user.delete({
where: { id: params.id },
})
return new NextResponse(null, { status: 204 })
}
// app/create-post/page.tsx
import { redirect } from 'next/navigation'
import { prisma } from '@/lib/prisma'
async function createPost(formData: FormData) {
'use server' // Server Action
const title = formData.get('title') as string
const content = formData.get('content') as string
await prisma.post.create({
data: { title, content },
})
redirect('/posts')
}
export default function CreatePostPage() {
return (
<form action={createPost}>
<input name="title" placeholder="Title" required />
<textarea name="content" placeholder="Content" required />
<button type="submit">Create</button>
</form>
)
}
'use client'
// ❌ 悪い例
import { prisma } from '@/lib/prisma'
export function UserList() {
const users = await prisma.user.findMany() // エラー!
}
// ✅ 良い例(Server Component)
import { prisma } from '@/lib/prisma'
export default async function UserList() {
const users = await prisma.user.findMany()
return <ul>{/* ... */}</ul>
}
// ❌ 悪い例
'use client' // 不要(インタラクティブでない)
export function UserCard({ user }: { user: User }) {
return <div>{user.name}</div>
}
// ✅ 良い例(Server Component)
export function UserCard({ user }: { user: User }) {
return <div>{user.name}</div>
}
新規ページ作成
/about ページを作成してください。
会社概要、ミッション、チーム紹介を含めてください。
API Route作成
/api/posts のCRUD APIを作成してください。
Prismaを使用して、GET, POST, PUT, DELETEをサポートしてください。
Server Actions実装
ユーザー作成フォームをServer Actionsで実装してください。
バリデーションも含めてください。
Last updated: 2025-12-26
tools
Fundamentals of modern web development. Framework selection (React, Vue, Next.js), project architecture, state management, routing, build tools, and CSS strategy best practices.
development
# React Development — Complete Guide > A comprehensive guide to building modern React applications with TypeScript. Covers fundamentals through advanced patterns, Hooks mastery, TypeScript integration, performance optimization, and algorithm internals. ## Target Audience - Developers new to React who want a solid foundation - Intermediate React developers looking to deepen their understanding of Hooks and TypeScript patterns - Engineers who want to understand React's internal algorithms (Virt
development
# Node.js Development Skill > A practical guide collection for Node.js development. Covers all aspects of Node.js application development, including Express, NestJS, asynchronous patterns, and performance optimization. ## Overview This skill covers the following topics: - **Express & NestJS**: When to use a lightweight framework vs. an enterprise framework - **Asynchronous Patterns**: Promise, async/await, Event Emitter, Streams, Worker Threads, Cluster - **Performance Optimization**: Memory
development
# Backend Development — Complete Guide > A comprehensive guide to backend engineering. Covers the fundamentals of HTTP, REST API design, databases, authentication, environment configuration, and algorithm proofs — everything needed to build robust server-side systems. ## Target Audience - Developers new to backend engineering - Frontend engineers expanding toward full-stack development - Engineers looking to solidify their understanding of server-side fundamentals ## Prerequisites - Basic p