Route Groups
Route groups let you organize routes without affecting the URL path. They're defined using parentheses: (folderName).
Basic Usage
Group related routes without adding URL segments:
app/
โโโ (marketing)/
โ โโโ about/
โ โ โโโ page.tsx โ /about
โ โโโ blog/
โ โ โโโ page.tsx โ /blog
โ โโโ pricing/
โ โโโ page.tsx โ /pricing
โโโ (dashboard)/
โโโ settings/
โ โโโ page.tsx โ /settings
โโโ profile/
โโโ page.tsx โ /profile
Notice: (marketing) and (dashboard) don't appear in URLs.
Multiple Layouts
The main use case: different layouts for different sections.
app/
โโโ (marketing)/
โ โโโ layout.tsx โ Marketing layout
โ โโโ page.tsx โ / (homepage)
โ โโโ about/
โ โ โโโ page.tsx
โ โโโ pricing/
โ โโโ page.tsx
โโโ (app)/
โโโ layout.tsx โ App layout
โโโ dashboard/
โ โโโ page.tsx
โโโ settings/
โโโ page.tsx
// app/(marketing)/layout.tsx
export default function MarketingLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div>
<MarketingHeader />
{children}
<MarketingFooter />
</div>
)
}
// app/(app)/layout.tsx
export default function AppLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div>
<Sidebar />
<main>{children}</main>
</div>
)
}
Multiple Root Layouts
You can have multiple root layouts for completely different app sections:
app/
โโโ (marketing)/
โ โโโ layout.tsx โ Own <html>, <body>
โ โโโ page.tsx
โโโ (dashboard)/
โโโ layout.tsx โ Different <html>, <body>
โโโ page.tsx
// app/(marketing)/layout.tsx
export default function MarketingLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className="marketing-theme">
{children}
</body>
</html>
)
}
// app/(dashboard)/layout.tsx
export default function DashboardLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className="dashboard-theme">
{children}
</body>
</html>
)
}
Note: Navigation between different root layouts causes a full page reload.
Organizing by Feature
Group by feature or domain instead of type:
app/
โโโ (shop)/
โ โโโ products/
โ โ โโโ page.tsx
โ โโโ cart/
โ โ โโโ page.tsx
โ โโโ checkout/
โ โโโ page.tsx
โโโ (blog)/
โ โโโ posts/
โ โ โโโ page.tsx
โ โโโ categories/
โ โโโ page.tsx
โโโ (account)/
โโโ profile/
โ โโโ page.tsx
โโโ orders/
โโโ page.tsx
Combining with Other Patterns
With Dynamic Routes
app/
โโโ (shop)/
โโโ products/
โโโ [category]/
โโโ [id]/
โโโ page.tsx โ /products/shoes/nike-123
With Catch-All Routes
app/
โโโ (docs)/
โโโ [...slug]/
โโโ page.tsx โ /any/nested/path
With Parallel Routes
app/
โโโ (dashboard)/
โโโ layout.tsx
โโโ @stats/
โ โโโ page.tsx
โโโ @notifications/
โโโ page.tsx
Common Patterns
Auth vs Non-Auth Layouts
app/
โโโ (public)/
โ โโโ layout.tsx โ No auth required
โ โโโ page.tsx
โ โโโ pricing/
โโโ (protected)/
โโโ layout.tsx โ Requires auth
โโโ dashboard/
โโโ settings/
Versioned API or Layouts
app/
โโโ (v1)/
โ โโโ layout.tsx โ V1 design system
โโโ (v2)/
โโโ layout.tsx โ V2 design system
Summary
- Route groups use
(folderName)- parentheses don't affect URLs - Main use: apply different layouts to different sections
- Can create multiple root layouts (full page reload between them)
- Great for organizing by feature, auth status, or design version
- Combine freely with dynamic routes, parallel routes, etc.
Up next ยท Lesson 16 of 26
Middleware Patterns
3 min read
15 of 26 lessons done

