Teach parallel routes and slot patterns in Next.js 16. Use when implementing parallel routes, working with @slot syntax, or encountering missing default.tsx errors.
Teaches Next.js 16 parallel routes and slot patterns using `@folder` syntax. Use when implementing concurrent UI sections like modals or dashboards, or fixing `default.tsx` 404 errors.
/plugin marketplace add djankies/claude-configs/plugin install nextjs-16@claude-configsThis skill is limited to using the following tools:
Parallel routes allow you to simultaneously render multiple pages within the same layout. Each route is defined in a "slot" using the @folder naming convention.
Key characteristics:
@ prefix (e.g., @team, @analytics)app/
├── @team/
│ ├── page.tsx
│ └── default.tsx
├── @analytics/
│ ├── page.tsx
│ └── default.tsx
├── layout.tsx
└── page.tsx
The layout receives slots as props:
export default function Layout({
children,
team,
analytics,
}: {
children: React.ReactNode
team: React.ReactNode
analytics: React.ReactNode
}) {
return (
<div>
<div>{children}</div>
<div className="grid grid-cols-2 gap-4">
<div>{team}</div>
<div>{analytics}</div>
</div>
</div>
)
}
CRITICAL: Every slot MUST have a default.tsx file.
When navigating to a route that doesn't match the current slot, Next.js will render the default.tsx fallback. Without it, you'll get a 404 error.
export default function Default() {
return null
}
Common error:
Error: The default export is not a React Component in route: /@team
Solution: Add default.tsx to every @slot directory.
Parallel routes handle navigation differently than normal routes:
When navigating using <Link> or router.push():
When navigating via browser refresh or direct URL entry:
default.tsx files render for unmatched routesExample scenario:
app/
├── @modal/
│ ├── login/
│ │ └── page.tsx
│ └── default.tsx
├── layout.tsx
└── page.tsx
/ → @modal renders default.tsx/login → @modal renders login/page.tsx/, @modal renders default.tsxThis is why intercepting routes typically use parallel routes for modals.
Slots match based on the current URL segment:
app/
├── dashboard/
│ ├── @sidebar/
│ │ ├── settings/
│ │ │ └── page.tsx
│ │ └── default.tsx
│ ├── settings/
│ │ └── page.tsx
│ └── layout.tsx
└── page.tsx
At /dashboard/settings:
dashboard/settings/page.tsx renders in childrendashboard/@sidebar/settings/page.tsx renders in sidebar slot@sidebar/settings/page.tsx doesn't exist, @sidebar/default.tsx rendersYou can conditionally render slots:
export default function Layout({
children,
modal,
auth,
}: {
children: React.ReactNode
modal: React.ReactNode
auth: React.ReactNode
}) {
const session = await getSession()
return (
<div>
{children}
{modal}
{!session && auth}
</div>
)
}
Problem: 404 errors when navigating
Solution: Add default.tsx to every slot directory
Problem: Slot prop is undefined in layout
Solution: Check slot name matches @folder name (case-sensitive)
Problem: Slot resets to default on navigation
Solution: Ensure target route exists in slot, or use default.tsx intentionally
Problem: Slots not accessible in nested layouts Solution: Slots only pass to immediate parent layout, not descendants
Problem: Confusion about where to place @slot folders
Solution: Place slots at the same level as the layout that consumes them
app/
├── (marketing)/
│ ├── @hero/
│ │ └── page.tsx
│ ├── layout.tsx
│ └── page.tsx
app/
├── @modal/
│ ├── (.)photo/
│ │ └── [id]/
│ │ └── page.tsx
│ └── default.tsx
├── photo/
│ └── [id]/
│ └── page.tsx
├── layout.tsx
└── page.tsx
Layout with modal slot:
export default function Layout({
children,
modal,
}: {
children: React.ReactNode
modal: React.ReactNode
}) {
return (
<>
{children}
{modal}
</>
)
}
Modal slot default:
export default function Default() {
return null
}
Intercepted route renders in modal:
export default function PhotoModal({ params }: { params: { id: string } }) {
return (
<dialog open>
<img src={`/photos/${params.id}.jpg`} />
</dialog>
)
}
Direct route renders full page:
export default function PhotoPage({ params }: { params: { id: string } }) {
return (
<main>
<img src={`/photos/${params.id}.jpg`} />
</main>
)
}
Good use cases:
Avoid when:
ROUTING-intercepting-routesROUTING-route-groupsMaster authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.