From dev
Next.js CLI expert for React development. Use when users need to create, develop, build, or deploy Next.js applications.
npx claudepluginhub leobrival/livenexx-plugin --plugin devThis skill is limited to using the following tools:
Next.js is a React framework for building full-stack web applications with features like file-based routing, server-side rendering, and API routes. This guide provides essential workflows and quick references for common Next.js operations.
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Next.js is a React framework for building full-stack web applications with features like file-based routing, server-side rendering, and API routes. This guide provides essential workflows and quick references for common Next.js operations.
# Create new Next.js app (interactive)
npx create-next-app@latest
# Create with specific name
npx create-next-app@latest my-app
# Start development server
cd my-app
npm run dev
# Build for production
npm run build
# Start production server
npm run start
# Run linter
npm run lint
# Create new app with TypeScript and Tailwind
npx create-next-app@latest my-app \
--typescript \
--tailwind \
--app \
--use-pnpm
# Navigate to project
cd my-app
# Start development server with Turbopack
npm run dev -- --turbopack
# Open browser to http://localhost:3000
# Create new route (App Router)
mkdir -p app/about
touch app/about/page.tsx
# Create dynamic route
mkdir -p app/blog/[slug]
touch app/blog/[slug]/page.tsx
# Create API route
mkdir -p app/api/users
touch app/api/users/route.ts
# Development server auto-reloads changes
// Server Component with data fetching
// app/posts/page.tsx
async function getPosts() {
const res = await fetch('https://api.example.com/posts', {
next: { revalidate: 60 } // ISR: revalidate every 60s
})
return res.json()
}
export default async function PostsPage() {
const posts = await getPosts()
return <div>{/* Render posts */}</div>
}
// API Route Handler
// app/api/users/route.ts
import { NextResponse } from 'next/server'
export async function GET() {
const users = await getUsers()
return NextResponse.json(users)
}
export async function POST(request: Request) {
const body = await request.json()
const user = await createUser(body)
return NextResponse.json(user, { status: 201 })
}
# Run linting and type checking
npm run lint
npm run type-check
# Build for production
npm run build
# Test production build locally
npm run start
# Deploy to Vercel
npm i -g vercel
vercel --prod
# Or deploy with Docker
# next.config.js: output: 'standalone'
docker build -t my-app .
docker run -p 3000:3000 my-app
# Check system information
next info
# Debug development server
NODE_OPTIONS='--inspect' next dev
# Debug build issues
next build --debug
# Profile React performance
next build --profile
# Analyze bundle size
ANALYZE=true next build
# Clear cache and rebuild
rm -rf .next node_modules
npm install
npm run build
When to use which command:
npx create-next-app@latest with appropriate flagsnext dev or next dev --turbopack for faster HMRpage.tsx files in app/ directory (App Router)route.ts files in app/api/ directory'use client'next build then next startnext lint --fixnext typegenapp/
├── page.tsx # Home page (/)
├── layout.tsx # Root layout
├── loading.tsx # Loading UI
├── error.tsx # Error boundary
├── not-found.tsx # 404 page
├── about/
│ └── page.tsx # /about route
├── blog/
│ ├── page.tsx # /blog route
│ └── [slug]/
│ └── page.tsx # /blog/:slug route
└── api/
└── users/
└── route.ts # /api/users endpoint
// Static Site Generation (SSG)
const res = await fetch('https://api.example.com/data', {
cache: 'force-cache'
})
// Incremental Static Regeneration (ISR)
const res = await fetch('https://api.example.com/data', {
next: { revalidate: 60 }
})
// Server-Side Rendering (SSR)
const res = await fetch('https://api.example.com/data', {
cache: 'no-store'
})
# .env.local (gitignored, local development)
DATABASE_URL=postgresql://localhost:5432/mydb
API_KEY=secret_key
# .env.production (production)
NEXT_PUBLIC_API_URL=https://api.example.com
# Client-side (prefixed with NEXT_PUBLIC_)
NEXT_PUBLIC_ANALYTICS_ID=G-XXXXXXXXXX
# Server-only (no prefix)
DATABASE_PASSWORD=secret
Common Issues:
Port already in use
next dev -p 3001 or kill process with lsof -ti:3000 | xargs kill -9Hydration errors
'use client' and useEffect for client-only contentBuild fails with memory error
NODE_OPTIONS='--max-old-space-size=4096' next buildModule not found errors
rm -rf .next node_modules && npm installEnvironment variables not working
NEXT_PUBLIC_ prefix for client-side, rebuild appFor detailed troubleshooting steps, see the Troubleshooting Guide.
Load as needed for detailed information:
Commands Reference - Complete CLI command documentation with all flags and options. Use when you need exact syntax or flag details for create-next-app, next dev, next build, next start, next lint, and other commands.
Common Patterns - Real-world patterns for App Router, data fetching, API routes, configuration, deployment, and performance optimization. Use for implementing routing, SSR/SSG/ISR, dynamic imports, or CI/CD pipelines.
Troubleshooting Guide - Detailed error messages, diagnosis steps, and resolution strategies for development, build, runtime, routing, and deployment issues. Use when encountering errors like hydration mismatches, build failures, or 404s.
When to use each reference: