nextjs-routes-and-layouts

Plan, implement, and refactor Next.js App Router routes and layouts.

2|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/AgentiveCity/SkillFactory --skill nextjs-routes-and-layouts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-routes-and-layouts
Source: https://github.com/AgentiveCity/SkillFactory/tree/main/.claude/skills/nextjs-routes-and-layouts
Command: npx skills add https://github.com/AgentiveCity/SkillFactory --skill nextjs-routes-and-layouts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing, refactoring, and extending Next.js App Router routes, layouts, and navigation patterns can be intricate, especially with dynamic routes, route groups, and server/client component boundaries. This Skill simplifies the process, ensuring best practices for navigation and UI structure, saving you time and reducing complexity.

Core Features & Use Cases

  • Automated Route & Layout Creation: Plan and implement new routes, nested routes, and shared UI shells (e.g., dashboards) with layout.tsx and page.tsx.
  • Dynamic & Parallel Routing: Set up dynamic routes ([slug]), catch-all routes, parallel routes, and intercepting routes for advanced UI patterns.
  • Server/Client Component Optimization: Correctly choose between server and client components to optimize performance and maintain clear boundaries.

Quick Start

Create a separate marketing and app layout, but keep URLs the same, and add dynamic routing for blog posts at /blog/[slug] with proper 404 handling.

Frequently Asked Questions about nextjs-routes-and-layouts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I organize routes and layouts in Next.js App Router?

Next.js App Router uses a file-based routing system where `layout.tsx` files define shared UI shells and `page.tsx` files define route content. Nest these files in directories to create hierarchical routes, and use route groups (folders in parentheses) to organize routes without affecting URLs.

How do I create dynamic routes in Next.js with catch-all handling?

Dynamic routes use bracket notation: `[slug]` matches a single segment, `[...slug]` catches all remaining segments. Place these in directories alongside `page.tsx`, and add `not-found.tsx` to handle invalid routes gracefully.

When should I use server components vs. client components in Next.js App Router?

Server components execute on the server by default in App Router, reducing bundle size and enabling direct database access. Use client components only when you need interactivity, state, or browser APIs; this boundary ensures optimal performance and security.

Can I use shadcn/ui components with Next.js App Router layouts?

Yes, shadcn/ui components work with App Router. Mark shadcn/ui components as client components with 'use client' directives when they require interactivity, and import them into your `layout.tsx` or `page.tsx` files for consistent UI across routes.

How do I set up parallel routes and intercepting routes in Next.js?

Parallel routes use folder syntax like `@sidebar` to render multiple segments simultaneously in the same layout. Intercepting routes use `(..)folder` or `(...)folder` notation to intercept and display alternative content while maintaining the URL, enabling modals and detailed views.

What special files does Next.js App Router support for error handling and loading states?

App Router provides `error.tsx` for error boundaries, `loading.tsx` for Suspense fallbacks, `not-found.tsx` for 404 responses, and `template.tsx` for per-route state reset. Use `default.tsx` in parallel routes when no match exists.