)
}
```
Layout characteristics:
- Preserve state during navigation
- Do not re-render on navigation between child routes
- Can fetch data
- Cannot access pathname or searchParams (use Client Component)
## Route Groups
Organize routes without affecting URL structure:
```
app/
├── (marketing)/ # Group without URL segment
│ ├── about/page.tsx → /about
│ ├── blog/page.tsx → /blog
│ └── layout.tsx # Marketing layout
├── (shop)/
│ ├── products/page.tsx → /products
│ ├── cart/page.tsx → /cart
│ └── layout.tsx # Shop layout
└── layout.tsx # Root layout
```
Use cases:
- Multiple root layouts
- Organize code by feature/team
- Different layouts for different sections
## Parallel Routes
Render multiple pages simultaneously in same layout:
```
app/
├── @team/ # Named slot
│ └── page.tsx
├── @analytics/ # Named slot
│ └── page.tsx
├── page.tsx # Default children
└── layout.tsx # Consumes slots
```
```tsx
// app/layout.tsx
export default function Layout({
children,
team,
analytics,
}: {
children: React.ReactNode
team: React.ReactNode
analytics: React.ReactNode
}) {
return (
<>
{children}
{team}
{analytics}
>
)
}
```
Use cases:
- Split views (dashboards)
- Modals
- Conditional rendering based on auth state
## Intercepting Routes
Intercept navigation to show content in different context:
```
app/
├── feed/
│ └── page.tsx
├── photo/
│ └── [id]/
│ └── page.tsx # Full photo page
└── (..)photo/ # Intercepts /photo/[id]
└── [id]/
└── page.tsx # Modal photo view
```
Matching conventions:
- `(.)` - Match same level
- `(..)` - Match one level above
- `(..)(..)` - Match two levels above
- `(...)` - Match from app root
Use case: Display modal when navigating from feed, show full page when URL accessed directly
## Loading States
### Loading File
Automatically wraps page in Suspense:
```tsx
// app/dashboard/loading.tsx
export default function Loading() {
return