Agent skill
nextjs-app-router
Next.js 15 App Router patterns for this project. Use when creating routes, API endpoints, server components, or client components.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/nextjs-app-router
SKILL.md
Next.js 15 App Router
Directory Structure
app/- Routes and API handlersclient/- Client components and utilitiesserver/- Server-side servicesshared/- Shared types and utilities
Route Handlers (API)
// app/api/example/route.ts
import { NextRequest, NextResponse } from 'next/server';
export async function POST(request: NextRequest) {
const body = await request.json();
// Validate with zod schema from shared/validation/
return NextResponse.json({ data });
}
Server Components (Default)
// No 'use client' directive
export default async function Page() {
const data = await fetchData(); // Direct DB/API calls
return <div>{data}</div>;
}
Client Components
'use client';
// Required for: hooks, browser APIs, event handlers, state
import { useState } from 'react';
Data Fetching
- Server Components: Direct async/await
- Client Components: Use
client/utils/api-client.ts
Caching
// Revalidate every hour
export const revalidate = 3600;
// Or disable caching
export const dynamic = 'force-dynamic';
Error Handling
error.tsx- Error boundary per routenot-found.tsx- 404 handlingloading.tsx- Suspense fallback
Metadata
export const metadata = {
title: 'Page Title',
description: 'Page description',
};
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?