Route Groups
Route groups allow you to organize your files and apply layouts without affecting the URL structure. They’re created using parentheses(group) in folder names.
What Are Route Groups?
Route groups are folders wrapped in parentheses that:- Don’t appear in URLs -
(auth)/login.tsxbecomes/login, not/(auth)/login - Organize files logically - Group related routes together
- Apply different layouts - Each group can have its own
_layout.tsx - Share settings - Configure navigation per group
Creating Route Groups
Wrap a folder name in parentheses:(auth) and (app) are invisible in URLs.
Basic Example
Without Route Groups
auth/ prefix.
With Route Groups
(auth) prefix.
Multiple Layouts
Use groups to apply different layouts to different sections:Root Layout
app/_layout.tsx
Auth Layout
app/(auth)/_layout.tsx
Tabs Layout
app/(tabs)/_layout.tsx
Array Syntax
Share layouts across multiple groups using array syntax:CLAUDE.md:210-212:
Array Syntax Example
app/(shop,cart,checkout)/_layout.tsx
(shop)/routes(cart)/routes(checkout)/routes
Organizing by Feature
Group routes by feature or domain:Nested Route Groups
Groups can be nested:app/(app)/_layout.tsx
Initial Route Configuration
Set different initial routes per group:app/(tabs)/_layout.tsx
navigation.test.ios.tsx:21-40):
Common Patterns
Authentication Flow
Separate authenticated and unauthenticated routes:app/_layout.tsx
Platform-Specific Groups
Different layouts for mobile and web:app/(mobile)/_layout.tsx
Multi-Tenant Apps
Different sections for different user types:E-commerce Flow
Dashboard with Sections
Best Practices
Use Descriptive Names
Keep Groups Focused
Match Navigation Structure
Use Array Syntax Carefully
Only use array syntax when layouts are truly identical:Debugging Route Groups
Check Segments
UseuseSegments() to see active groups:
View Route Structure
Visit/_sitemap in development to see all routes:
Common Issues
URLs include group names:Limitations
Cannot Have Same Route in Multiple Groups
Groups Don’t Affect Deep Linking
Deep links use the final URL:Advanced Patterns
Conditional Group Rendering
app/_layout.tsx
Group-Specific Context
app/(dashboard)/_layout.tsx
Shared Components Per Group
app/(admin)/_layout.tsx
Next Steps
Layouts
Learn more about layouts
File-Based Routing
Understand routing conventions
Stack Navigation
Configure stack navigation
Tab Navigation
Create tab navigation