wsimmonds/claude-nextjs-skills/nextjs-advanced-routing
Claude Code and agent skill by wsimmonds/claude-nextjs-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for advanced Next.js App Router patterns including Route Handlers, Parallel Routes, Intercepting Routes, Server Actions, error boundaries, draft mode, and streaming with Suspense. CRITICAL for server actions (action.ts, actions.ts files, 'use server' directive), setting cookies from client components, and form handling. Use when requirements involve server actions, form submissions, cookies, mutations, API routes, `route.ts`, parallel routes, intercepting routes, or streaming. Essential for separating server actions from client components.
Install
npx vskill@latest install wsimmonds/claude-nextjs-skills/nextjs-advanced-routingSKILL.md
Next.js Advanced Routing
Overview
Provide comprehensive guidance for advanced Next.js App Router features including Route Handlers (API routes), Parallel Routes, Intercepting Routes, Server Actions, error handling, draft mode, and streaming with Suspense.
TypeScript: NEVER Use any Type
CRITICAL RULE: This codebase has @typescript-eslint/no-explicit-any enabled. Using any will cause build failures.
❌ WRONG:
✅ CORRECT:
Common Next.js Type Patterns
When to Use This Skill
Use this skill when:
- Creating API endpoints with Route Handlers
- Implementing parallel or intercepting routes
- Building forms with Server Actions
- Setting cookies or handling mutations
- Creating error boundaries
- Implementing draft mode for CMS previews
- Setting up streaming and Suspense boundaries
- Building complex routing patterns (modals, drawers)
⚠️ CRITICAL: Server Action File Naming and Location
When work requirements mention a specific filename, follow that instruction exactly. If no name is given, pick the option that best matches the project conventions—app/actions.ts is a safe default for collections of actions, while app/action.ts works for a single form handler.
Choosing between action.ts and actions.ts
- Match existing patterns: Check whether the project already has an actions file and extend it if appropriate.
- Single vs multiple exports: Prefer
action.tsfor a single action, andactions.tsfor a group of related actions. - Explicit requirement: If stakeholders call out a specific name, do not change it.
Location guidelines
- Server actions belong under the
app/directory so they can participate in the App Router tree. - Keep the file alongside the UI that invokes it unless shared across multiple routes.
- Avoid placing actions in
lib/orutils/unless they are triggered from multiple distant routes and remain server-only utilities.
Example placement
Example: Creating action.ts
Example: Creating actions.ts
Remember: When a project requirement spells out an exact filename, mirror it precisely.
⚠️ CRITICAL: Server Actions Return Types - Form Actions MUST Return Void
This is a TypeScript requirement, not optional. Even if you see code that returns data from form actions, that code is WRONG.
When using form action attribute: <form action={serverAction}>
- The function MUST have no return statement (implicitly returns void)
- TypeScript will REJECT any return value, even
return undefinedorreturn null - IMPORTANT: If you see example code in the codebase that returns data from a form action, ignore it - it's an anti-pattern. Fix it by removing the return statement.
❌ WRONG (causes build error):
✅ CORRECT - Option 1 (Simple form action, no response):
✅ CORRECT - Option 2 (With useActionState for feedback):
The key rule: <form action={...}> expects void. If you need to return data, use useActionState.
Route Handlers (API Routes)
Basic Route Handler
Route Handlers replace API Routes from the Pages Router. Create them in route.ts or route.js files.
Supported HTTP Methods
Dynamic Route Handlers
Request Headers and Cookies
Setting Cookies in Route Handlers
CORS Configuration
Streaming Responses
Server Actions
Server Actions enable server-side mutations without creating API endpoints.
Basic Server Action (Without Return)
Note: See "Using Server Actions in Forms" section below for patterns that return data vs. those that don't.
⚠️ CRITICAL: Server Actions File Organization
File Naming Precision:
- When stakeholders specify a filename (e.g., “create a server action in a file called
action.ts”), mirror it exactly. - Common filenames:
action.ts(singular) oractions.ts(plural)—choose the one that matches the brief or existing code. - Place the file in the appropriate directory: typically
app/action.tsorapp/actions.ts.
Two Patterns for 'use server' Directive:
Pattern 1: File-level (recommended for multiple actions):
Pattern 2: Function-level (for single action or mixed file):
Client Component Calling Server Action:
When a client component needs to call a server action (e.g., onClick, form submission):
- Create the server action in a SEPARATE file with 'use server' directive
- Import and use it in the client component
✅ CORRECT Pattern:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingnextjs-advanced-routing/SKILL.md
Popularity
- Repository stars
- 75
- Repository forks
- 9
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wsimmonds/claude-nextjs-skills/nextjs-advanced-routing)