Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when working with Next.js App Router tasks - creating pages in /app/, setting up dynamic routes ([id]/page.tsx), implementing nested layouts/templates (layout.tsx), optimizing Server/Client components, or building ERP role-based pages (admin/teacher/student dashboards). Auto-use for all /app/ directory operations, dynamic routing, and App Router-specific features.
.claude/skills/aiskillstore-frontend-nextjs-app-router/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-19 | ✓→✗ | ▼ Worse | 108% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 23% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 77% | 0% |
| case-10 | ✓→✓ | = Same ✓ | 74% | 0% |
Expert guidance for Next.js App Router development including page creation, dynamic routing, nested layouts, Server/Client component optimization, and ERP role-based dashboards.
/app/.../page.tsx)Rules:
fetch() or ORM queries directlyuseEffect for initial data loadSuspense boundaries for loading statesgenerateMetadata()Template:
typescript// app/dashboard/page.tsx import { Suspense } from 'react'; import { TaskList } from '@/components/TaskList'; import { TaskListSkeleton } from '@/components/TaskListSkeleton'; export const metadata = { title: 'Dashboard', description: 'Your task management dashboard', }; export default async function DashboardPage() { const tasks = await fetchTasks(); return ( <main className="p-4"> <h1>Dashboard</h1> <Suspense fallback={<TaskListSkeleton />}> <TaskList initialTasks={tasks} /> </Suspense> </main> ); }
[slug]/page.tsx)When to use:
app/students/[studentId]/page.tsxapp/tasks/[taskId]/page.tsxapp/courses/[courseId]/page.tsxRules:
params prop (read-only)generateMetadata() for SEOnot-found.tsxTemplate:
typescript// app/students/[studentId]/page.tsx import { notFound } from 'next/navigation'; type Params = Promise<{ studentId: string }>; export async function generateMetadata({ params }: { params: Params }) { const { studentId } = await params; const student = await getStudent(studentId); if (!student) return { title: 'Student Not Found' }; return { title: `${student.name} - Student Profile`, }; } export default async function StudentProfile({ params }: { params: Params }) { const { studentId } = await params; const student = await getStudent(studentId); if (!student) notFound(); return <StudentProfileView student={student} />; }
@folder)When to use:
app/dashboard@(admin|teacher)/page.tsxapp/settings@(user|organization)/layout.tsxTemplate:
typescript// app/dashboard/@admin/page.tsx - Admin dashboard export default function AdminDashboard() { return <AdminPanel />; } // app/dashboard/@teacher/page.tsx - Teacher dashboard export default function TeacherDashboard() { return <TeacherPanel />; }
Root Layout (app/layout.tsx):
typescriptimport { Providers } from '@/components/Providers'; import './globals.css'; export const metadata = { title: 'Todo Evolution', description: 'Task management for education', }; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <body> <Providers>{children}</Providers> </body> </html> ); }
Nested Layout (app/dashboard/layout.tsx):
typescriptimport { DashboardNav } from '@/components/DashboardNav'; export default function DashboardLayout({ children, }: { children: React.ReactNode; }) { return ( <div className="flex min-h-screen"> <DashboardNav /> <main className="flex-1 p-6">{children}</main> </div> ); }
Template (app/tasks/template.tsx):
typescript// Re-executes on navigation, preserves form state export default function TasksTemplate({ children }: { children: React.ReactNode }) { return ( <div className="bg-gray-50 min-h-screen"> <header className="bg-white shadow"> <h1>Tasks</h1> </header> {children} </div> ); }
Use Server Components for:
Use Client Components ('use client') for:
window, localStorage)onClick, onSubmit)useState, useEffect)typescript// Server Component (default) export default async function TaskList() { const tasks = await fetchTasks(); // Direct DB query return <div>{tasks.map(/* ... */)}</div>; } // Client Component 'use client'; import { useTaskStore } from '@/store/tasks'; export function TaskFilter() { const { filter, setFilter } = useTaskStore(); return <button onClick={() => setFilter('all')}>All Tasks</button>; }
Role Guards:
typescript// app/admin/page.tsx import { requireRole } from '@/lib/auth'; import { redirect } from 'next/navigation'; export default async function AdminPage() { const session = await getSession(); if (session?.role !== 'admin') { redirect('/unauthorized'); } return <AdminDashboard />; }
KPI Dashboard (Recharts):
typescript'use client'; import { BarChart, Bar, XAxis, YAxis, Tooltip } from 'recharts'; export function TaskKPIChart({ data }: { data: TaskStats[] }) { return ( <BarChart width={600} height={300} data={data}> <XAxis dataKey="date" /> <YAxis /> <Tooltip /> <Bar dataKey="completed" fill="#22c55e" /> </BarChart> ); }
Error Boundary (error.tsx):
typescript'use client'; export default function Error({ error, reset, }: { error: Error & { digest?: string }; reset: () => void; }) { return ( <div> <h2>Something went wrong!</h2> <button onClick={reset}>Try again</button> </div> ); }
Loading State (loading.tsx):
typescriptexport default function Loading() { return <div className="animate-pulse">Loading...</div>; } // Or with Suspense: export default async function Page() { return ( <Suspense fallback={<Loading />}> <Content /> </Suspense> ); }
Installation:
bashnpx shadcn@latest add button card input dialog
Usage in Server Components:
typescriptimport { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; export default async function TaskPage() { const tasks = await getTasks(); return ( <Card> <CardHeader>Tasks</CardHeader> <CardContent> {tasks.map(task => ( <div key={task.id}>{task.title}</div> ))} </CardContent> </Card> ); }
User Request → Analyze → Implementation Path
→ Server Component with page.tsx → Async data fetch → Add layout.tsx if navigation needed
→ Create [studentId]/page.tsx → Extract params → Add generateMetadata() → Create not-found.tsx if needed
→ Create layout.tsx in target folder → Wrap with providers if needed → Maintain children render
→ 'use client' component → useState for form data → Server Action for submission OR API route
→ 'use client' for Recharts → Server Component parent with data fetch → Pass data as props
Before marking task complete:
'use client' only when necessarygenerateMetadata() for SEOerror.tsx) where neededPattern 1: Server Component + Client Component Mix
typescript// Server Component export default async function Page() { const tasks = await fetchTasks(); return <TaskList tasks={tasks} />; // Client component for interactivity } 'use client'; function TaskList({ tasks }: { tasks: Task[] }) { const [filter, setFilter] = useState('all'); const filtered = tasks.filter(/* ... */); return <div>{filtered.map(/* ... */)}</div>; }
Pattern 2: Route Groups for Organization
app/
(marketing)/ # Group: no URL segment
about/page.tsx
contact/page.tsx
(dashboard)/ # Group: no URL segment
layout.tsx
page.tsxPattern 3: API Routes (Route Handlers)
typescript// app/api/tasks/route.ts import { NextResponse } from 'next/server'; export async function GET() { const tasks = await db.query.tasks.findMany(); return NextResponse.json(tasks); } export async function POST(request: Request) { const body = await request.json(); const task = await createTask(body); return NextResponse.json(task, { status: 201 }); }
app/dashboard/page.tsx with server componentapp/students/[studentId]/page.tsx with params and metadataapp/dashboard/layout.tsx with children'use client' form component + API routeapp/not-found.tsxapp/dashboard/error.tsxSee references/app-router-patterns.md for advanced patterns and references/api-routes.md for route handler examples.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 27,210 | 22,619 | -17% | 1 | 1 | 0% | 4,525 | 6,421 | +42% | 0 | 0 | — |
case-02 | pass→pass | 25,243 | 18,183 | -28% | 1 | 1 | 0% | 4,582 | 5,619 | +23% | 0 | 0 | — |
case-03 | pass→pass | 20,084 | 17,889 | -11% | 1 | 1 | 0% | 2,999 | 5,320 | +77% | 0 | 0 | — |
case-10 | pass→pass | 14,355 | 11,630 | -19% | 1 | 1 | 0% | 2,966 | 5,156 | +74% | 0 | 0 | — |
case-04 | pass→pass | 11,835 | 9,105 | -23% | 1 | 1 | 0% | 1,206 | 3,488 | +189% | 0 | 0 | — |
case-05 | pass→pass | 18,434 | 20,809 | +13% | 1 | 1 | 0% | 2,761 | 5,931 | +115% | 0 | 0 | — |
case-06 | pass→pass | 19,427 | 16,730 | -14% | 1 | 1 | 0% | 2,793 | 5,111 | +83% | 0 | 0 | — |
case-07 | pass→pass | 19,520 | 17,617 | -10% | 1 | 1 | 0% | 3,091 | 5,405 | +75% | 0 | 0 | — |
case-08 | pass→pass | 17,823 | 21,116 | +18% | 1 | 1 | 0% | 2,586 | 5,688 | +120% | 0 | 0 | — |
case-09 | pass→pass | 27,616 | 23,232 | -16% | 1 | 1 | 0% | 5,210 | 6,506 | +25% | 0 | 0 | — |
case-11 | pass→pass | 21,746 | 18,618 | -14% | 1 | 1 | 0% | 3,903 | 5,309 | +36% | 0 | 0 | — |
case-12 | pass→pass | 24,968 | 13,735 | -45% | 1 | 1 | 0% | 2,910 | 5,659 | +94% | 0 | 0 | — |
case-13 | pass→pass | 19,176 | 21,347 | +11% | 1 | 1 | 0% | 2,682 | 6,215 | +132% | 0 | 0 | — |
case-14 | pass→pass | 7,997 | 15,514 | +94% | 1 | 1 | 0% | 1,362 | 4,810 | +253% | 0 | 0 | — |
case-15 | pass→pass | 12,122 | 12,421 | +2% | 1 | 1 | 0% | 1,397 | 4,284 | +207% | 0 | 0 | — |
case-16 | pass→pass | 14,136 | 12,489 | -12% | 1 | 1 | 0% | 2,907 | 5,203 | +79% | 0 | 0 | — |
case-17 | pass→pass | 15,098 | 10,709 | -29% | 1 | 1 | 0% | 2,944 | 4,907 | +67% | 0 | 0 | — |
case-18 | pass→pass | 10,501 | 15,098 | +44% | 1 | 1 | 0% | 2,064 | 4,497 | +118% | 0 | 0 | — |
case-19 | pass→fail | 17,850 | 18,163 | +2% | 1 | 1 | 0% | 2,487 | 5,174 | +108% | 0 | 0 | — |
case-20 | pass→pass | 15,259 | 21,435 | +40% | 1 | 1 | 0% | 2,803 | 5,922 | +111% | 0 | 0 | — |
case-21 | pass→pass | 13,183 | 13,826 | +5% | 1 | 1 | 0% | 1,554 | 4,105 | +164% | 0 | 0 | — |
case-22 | pass→pass | 25,224 | 16,538 | -34% | 1 | 1 | 0% | 4,111 | 6,092 | +48% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of 0 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.