Skip to content

Next.js App Router expertise with five skills, three commands, and auth and performance guidance.

CCM score
67 of 100
version
1.0.0
GitHub stars
3.8K
View on GitHub

Own this plugin? Claim it

What it does

  • Adds 3 commands (/nextjs-expert:scaffold, /nextjs-expert:add-auth, /nextjs-expert:optimize) and 5 skills covering App Router, Server Components, Route Handlers, Server Actions, and auth
  • Covers file conventions, dynamic and parallel routes, server versus client component boundaries, and HTTP method handlers with streaming responses
  • Guides form handling with useFormState, Zod validation, and revalidation, plus NextAuth.js v5 with middleware-based route protection
  • Designed for projects targeting Next.js 15 that want patterns checked against App Router conventions

Next.js development expertise with skills for App Router, Server Components, Route Handlers, Server Actions, and authentication patterns

Add marketplace

/plugin marketplace add davepoon/buildwithclaude

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install nextjs-expert@buildwithclaude

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

Next.js App Router Patterns

Overview

The App Router is Next.js's file-system based router built on React Server Components. It uses a app/ directory structure where folders define routes and special files control UI behavior.

Core File Conventions

Route Files

Each route segment is defined by a folder. Special files within folders control behavior:

FilePurpose
page.tsxUnique UI for a route, makes route publicly accessible
layout.tsxShared UI wrapper, preserves state across navigations
loading.tsxLoading UI using React Suspense
error.tsxError boundary for route segment
not-found.tsxUI for 404 responses
template.tsxLike layout but re-renders on navigation
default.tsxFallback for parallel routes

Folder Conventions

PatternPurposeExample
folder/Route segmentapp/blog/ → /blog
[folder]/Dynamic segmentapp/blog/[slug]/ → /blog/:slug
[...folder]/Catch-all segmentapp/docs/[...slug]/ → /docs/*
[[...folder]]/Optional catch-allapp/shop/[[...slug]]/ → /shop or /shop/*
(folder)/Route group (no URL)app/(marketing)/about/ → /about
@folder/Named slot (parallel routes)app/@modal/login/
_folder/Private folder (excluded)app/_components/

Creating Routes

Basic Route Structure

To create a new route, add a folder with page.tsx:

app/
├── page.tsx              # / (home)
├── about/
│   └── page.tsx          # /about
└── blog/
    ├── page.tsx          # /blog
    └── [slug]/
        └── page.tsx      # /blog/:slug

Page Component

A page is a Server Component by default:

// app/about/page.tsx
export default function AboutPage() {
  return (
    <main>
      <h1>About Us</h1>
      <p>Welcome to our company.</p>
    </main>
  )
}

Dynamic Routes

Access route parameters via the params prop:

// app/blog/[slug]/page.tsx
interface PageProps {
  params: Promise<{ slug: string }>
}

export default async function BlogPost({ params }: PageProps) {
  const { slug } = await params
  const post = await getPost(slug)

  return <article>{post.content}</article>
}

Layouts

Root Layout (Required)

Every app needs a root layout with <html> and <body>:

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

Nested Layouts

Layouts wrap their children and preserve state:

// app/dashboard/layout.tsx
export default function DashboardLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <div className="flex">
      <Sidebar />
      <main className="flex-1">{children}</main>
    </div>
  )
}

Loading and Error States

Loading UI

Create instant loading states with Suspense:

// app/dashboard/loading.tsx
export default function Loading() {
  return <div className="animate-pulse">Loading...</div>
}

Error Boundaries

Handle errors gracefully:

// app/dashboard/error.tsx
'use client'

export default function Error({
  error,
  reset,
}: {
  error: Error
  reset: () => void
}) {
  return (
    <div>
      <h2>Something went wrong!</h2>
      <button onClick={reset}>Try again</button>
    </div>
  )
}

Route Groups

Organize routes without affecting URL structure:

app/
├── (marketing)/
│   ├── layout.tsx        # Marketing layout
│   ├── about/page.tsx    # /about
│   └── contact/page.tsx  # /contact
└── (shop)/
    ├── layout.tsx        # Shop layout
    └── products/page.tsx # /products

Metadata

Static Metadata

// app/about/page.tsx
import { Metadata } from 'next'

export const metadata: Metadata = {
  title: 'About Us',
  description: 'Learn more about our company',
}

Dynamic Metadata

// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
  const { slug } = await params
  const post = await getPost(slug)
  return { title: post.title }
}

Key Patterns

  1. Colocation: Keep components, tests, and styles near routes
  2. Private folders: Use _folder for non-route files
  3. Route groups: Use (folder) to organize without URL impact
  4. Parallel routes: Use @slot for complex layouts
  5. Intercepting routes: Use (.) patterns for modals

Resources

For detailed patterns, see:

  • references/routing-conventions.md - Complete file conventions
  • references/layouts-templates.md - Layout composition patterns
  • references/loading-error-states.md - Suspense and error handling
  • examples/dynamic-routes.md - Dynamic routing examples
  • examples/parallel-routes.md - Parallel and intercepting routes

Readme

Next.js Expert Plugin

A comprehensive Claude Code plugin providing Next.js development expertise with skills for App Router, Server Components, Route Handlers, Server Actions, and authentication patterns.

Features

  • 5 Skills covering core Next.js App Router concepts
  • 3 Commands for common development tasks
  • Progressive disclosure with references and examples
  • Next.js 15 compatible patterns

Installation

Add to your Claude Code settings:

{
  "plugins": [
    "https://github.com/davepoon/buildwithclaude/tree/main/plugins/nextjs-expert"
  ]
}

Skills

app-router

File-based routing, layouts, metadata, and route organization for Next.js App Router.

Topics covered:

  • File conventions (page.tsx, layout.tsx, loading.tsx, error.tsx)
  • Dynamic routes and catch-all segments
  • Parallel routes and intercepting routes
  • Route groups and organization

server-components

React Server Components patterns and when to use server vs client components.

Topics covered:

  • Server vs Client component decision guide
  • 'use client' boundaries
  • Composition patterns
  • Data fetching in server components

route-handlers

API route handlers in the app directory.

Topics covered:

  • HTTP method handlers (GET, POST, PUT, PATCH, DELETE)
  • Request/response handling
  • Streaming responses
  • CORS and authentication

server-actions

Server Actions for form handling and mutations.

Topics covered:

  • 'use server' directive
  • Form handling with useFormState
  • Validation with Zod
  • Revalidation patterns

auth-patterns

Authentication patterns for Next.js applications.

Topics covered:

  • NextAuth.js v5 setup
  • Middleware-based route protection
  • Session management
  • Role-based access control

Commands

/nextjs-expert:scaffold

Scaffold Next.js components following best practices.

/nextjs-expert:scaffold

Scaffolds pages, components, API routes, and more following App Router conventions.

/nextjs-expert:add-auth

Add authentication to a Next.js application.

/nextjs-expert:add-auth

Sets up NextAuth.js with providers, middleware, and protected routes.

/nextjs-expert:optimize

Analyze and optimize Next.js application performance.

/nextjs-expert:optimize

Reviews component boundaries, data fetching, caching, and provides recommendations.

Directory Structure

nextjs-expert/
├── .claude-plugin/
│   └── plugin.json
├── skills/
│   ├── app-router/
│   │   ├── SKILL.md
│   │   ├── references/
│   │   │   ├── routing-conventions.md
│   │   │   ├── layouts-templates.md
│   │   │   └── loading-error-states.md
│   │   └── examples/
│   │       ├── dynamic-routes.md
│   │       └── parallel-routes.md
│   ├── server-components/
│   │   ├── SKILL.md
│   │   ├── references/
│   │   │   ├── server-vs-client.md
│   │   │   └── composition-patterns.md
│   │   └── examples/
│   │       └── data-fetching-patterns.md
│   ├── route-handlers/
│   │   ├── SKILL.md
│   │   ├── references/
│   │   │   ├── http-methods.md
│   │   │   └── streaming-responses.md
│   │   └── examples/
│   │       └── crud-api.md
│   ├── server-actions/
│   │   ├── SKILL.md
│   │   ├── references/
│   │   │   ├── form-handling.md
│   │   │   └── revalidation.md
│   │   └── examples/
│   │       └── mutation-patterns.md
│   └── auth-patterns/
│       ├── SKILL.md
│       ├── references/
│       │   ├── middleware-auth.md
│       │   └── session-management.md
│       └── examples/
│           └── nextauth-setup.md
├── commands/
│   ├── scaffold.md
│   ├── add-auth.md
│   └── optimize.md
└── README.md

Usage Examples

Building a new page

Ask Claude:

"Create a blog post page with dynamic routing"

Claude will use the app-router and server-components skills to generate:

  • app/blog/[slug]/page.tsx with proper async params
  • Loading and error states
  • Metadata generation

Adding authentication

Ask Claude:

"Add GitHub and Google authentication to my app"

Or use the command:

"/nextjs-expert:add-auth"

Claude will use the auth-patterns skill to set up:

  • NextAuth.js configuration
  • Middleware protection
  • Login/logout components

Optimizing performance

Ask Claude:

"Review my app for performance issues"

Or use the command:

"/nextjs-expert:optimize"

Claude will analyze:

  • Client/server component boundaries
  • Data fetching patterns
  • Caching strategies
  • Bundle size

Contributing

Contributions welcome! Please follow the existing skill structure and include:

  • SKILL.md with frontmatter and core content
  • References for detailed documentation
  • Examples with working code patterns

License

MIT

Details

Marketplace
davepoon/buildwithclaude
Source
plugins/nextjs-expert
Author
BuildWithClaude Community
Category
Development
License
MIT
Keywords
skills, nextjs, react, app-router, server-components, route-handlers, server-actions, authentication
Listed since
Apr 6, 2026

More from davepoon/buildwithclaude

All 257

Similar to nextjs-expert

More Frontend & UI Code