Parallel Routes Layout
Next.js parallel routes pattern to render multiple page slots simultaneously in a shared layout.
// app/dashboard/layout.tsx
// Parallel routes use @folder convention for named slots
export default function DashboardLayout({
children,
analytics,
notifications,
}: {
children: React.ReactNode;
analytics: React.ReactNode;
notifications: React.ReactNode;
}) {
return (
<div className="grid grid-cols-12 gap-6 p-6">
{/* Main content */}
<div className="col-span-8">{children}</div>
{/* Sidebar with parallel slots */}
<div className="col-span-4 space-y-6">
{analytics}
{notifications}
</div>
</div>
);
}
// File structure:
// app/dashboard/
// layout.tsx <- this file
// page.tsx <- renders in {children}
// @analytics/
// page.tsx <- renders in {analytics}
// loading.tsx <- independent loading state
// @notifications/
// page.tsx <- renders in {notifications}
// loading.tsx <- independent loading state
//
// Each slot loads independently with its own loading/error states.
// Navigation preserves all slots — no full page reload.Sponsored
Vercel — Deploy Next.js with zero config
Use Cases
- Dashboard multi-panel layouts
- Side-by-side views
- Independent loading states
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
Intercepting Routes Modal
Show content in a modal on soft navigation while preserving the full page on hard navigation.
Type-Safe API Route Handler
Next.js App Router route handler with input validation, typed responses, and proper error handling.
Authentication Middleware Guard
Next.js middleware that checks auth tokens on protected routes and redirects unauthenticated users to login.
Server Action with Form Validation
Next.js Server Action handling form submissions with validation, error messages, and redirect on success.