Basic nested layouts
Use theOutlet component to render child routes:
File-based layout structure
Organize layouts using file structure:Pathless layouts
Create layouts that don’t add to the URL path using_ prefix:
src/routes/_auth.tsx
Multiple layout levels
Nest layouts within layouts:Layout with shared data
Load data in parent and access in children:src/routes/dashboard.tsx
src/routes/dashboard/settings.tsx
Layout context
Share state between parent and child routes:src/routes/dashboard.tsx
Active link styling
Highlight active navigation items:Layout groups
Group routes without affecting the URL:Conditional layouts
Render different layouts based on conditions:Pending states in layouts
Show loading states while child routes load:Best practices
Keep layouts minimal
Keep layouts minimal
Layouts should focus on structure and shared UI, not business logic.
Use pathless routes for auth
Use pathless routes for auth
Wrap protected routes in pathless layouts for clean URLs.
Leverage layout context
Leverage layout context
Use React Context for sharing state between layouts and children.
Next steps
Data loading
Share data between layouts
Routes concept
Deep dive into route configuration