Communitygithub.com

ComeOnOliver/skillshub

正しいパターンと特徴的なデザインでNext.js 16アプリケーションを構築します。ページ、レイアウト、動的ルート作成、Next.js 15からのアップグレード、proxy.tsの実装時に使用します。破壊的変更(非同期params/searchParams、Turbopack、cacheComponents)とフロントエンドの美学をカバーします。非Reactアプリケーションやバックエンド専用アプリケーションの構築には使用しません。

skillshub とは?

このスキルは、Next.js 16アプリケーションを正しいパターンと特徴的なデザインで構築するための包括的なガイドです。Next.js 15から16への移行時に発生する重要な破壊的変更、特に`params`と`searchParams`がPromiseになった点、クライアントコンポーネントでの`use()`フックの使用、Turbopackの変更、cacheComponentsの設定などを詳細にカバーしています。また、App Routerを使用したレイアウト、動的ルート、サーバーアクション、APIルート、`proxy.ts`を使用したミドルウェアの実装など、Next.js 16の主要なパターンを具体的なコード例とともに示しています。データフェッチングのベストプラクティス(サーバーコンポーネントとクライアントコンポーネントの両方)とプロジェクト構造の推奨事項も含まれています。さらに、`next-devtools-mcp`サーバーを使用したランタイム診断と自動化の方法、Next.js 16の組み込みMCPエンドポイントについても解説しており、開発効率を大幅に向上させることができます。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/asmayaseen/building-nextjs-apps

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

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

ドキュメント

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. クライアントコンポーネントは use() フックが必要

"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 レイアウト

// app/layout.tsx
export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body className="min-h-screen">
        {children}
      </body>
    </html>
  )
}

動的ルート

// 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>
  )
}

サーバーアクション

// 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">作成</button>
</form>

API ルート

// 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 })
}

ミドルウェア → 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*"],
}

データフェッチング

サーバーコンポーネント (デフォルト)

// これはサーバー上で実行されます - 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>
  )
}

クライアントコンポーネント

"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>読み込み中...</div>
  if (error) return <div>タスクの読み込み中にエラーが発生しました</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"]
    }
  }
}

利用可能なツール

ツール目的
init利用可能なツールとベストプラクティスでコンテキストを確立
nextjs_docs公式Next.jsドキュメントの検索と取得
browser_evalPlaywrightを使用したブラウザテストの自動化
nextjs_index実行中のNext.js開発サーバーの検出
nextjs_call実行中の開発サーバーでMCPツールを実行
upgrade_nextjs_16codemodsを使用した自動アップグレード
enable_cache_componentsNext.js 16 の Cache Components を設定

主なユースケース

1. リアルタイムエラーの取得

"私のNext.jsアプリにどのようなビルドエラーがありますか?"
"現在のプロジェクトのTypeScriptエラーを表示してください"

2. ランタイム問題のデバッグ

"開発サーバーのログでエラーを確認してください"
"ダッシュボードページで発生しているランタイムエラーは何ですか?"

3. アップグレード支援

"このプロジェクトをNext.js 16にアップグレードしてください"
"このアプリでcache componentsを有効にしてください"

4. ドキュメント検索

"Next.js 16 で Image コンポーネントを使用するにはどうすればよいですか?"
"動的ルートを正しく処理する方法は?"

Next.js 16 MCP エンドポイント

Next.js 16+ は、http://localhost:3000/_next/mcp(または開発サーバーのポート)に組み込みのMCPエンドポイントを公開します。devtools MCPは自動的に実行中のサーバーを検出して接続します。


検証

実行: python3 scripts/verify.py

期待される出力: ✓ building-nextjs-apps skill ready

検証に失敗した場合

  1. 確認: references/ フォルダに nextjs-16-patterns.md があるか
  2. それでも失敗する場合は 停止して報告

関連スキル

  • styling-with-shadcn - Next.jsアプリケーション用UIコンポーネント
  • fetching-library-docs - 最新のNext.jsドキュメント: --library-id /vercel/next.js --topic routing
  • configuring-better-auth - Next.jsアプリケーション用OAuth/SSO

リファレンス

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

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.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Next.js 16+ uses App Router with Server Components by default. Client Components are only used when interactivity is needed (hooks, event handlers, browser APIs).

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル