Adding New Screens to the Mobile App
This guide walks you through adding new screens to the Launch mobile app, including proper navigation setup, route registration, and navigation guards.Overview
The Launch mobile app uses a nested navigation structure with NativeTabs inside an AppStack:Prerequisites
- Expo Router basics
- App running locally
Steps
Step-by-Step Process
1. Create the Screen Component
Create your screen file in theapp/ directory:
File: apps/mobile/app/your-screen.tsx
2. Customize Screen Options (Optional)
Expo Router uses file-based routing, so your screen is registered automatically. If you want custom header options, add them to the layout: File:apps/mobile/app/_layout.tsx or apps/mobile/app/(tabs)/_layout.tsx
3. Adjust Redirect Rules (if needed)
If the screen should be reachable during onboarding or auth flows, update the redirect logic inapps/mobile/lib/hooks/useAppNavigation.ts.
4. Add Navigation from Other Screens
To navigate to your screen from within tabs (like Explore): From within a tab screen:Navigation Patterns
From Tabs to AppStack Routes
When navigating from inside tabs to AppStack routes, you need to access the grandparent navigator:Direct AppStack Navigation
For routes at the same level in AppStack:Back Navigation
Back navigation works automatically with the configuredheaderBackTitle:
- iOS: Shows ”< Features” or custom back title
- Android: Shows standard back arrow
- Gesture: Swipe from edge works automatically
Screen Types and Presentations
Card Presentation (Recommended)
Modal Presentation
Fullscreen Presentation
Navigation Guards
Navigation guards live inapps/mobile/lib/hooks/useAppNavigation.ts and handle:
- Redirecting unauthenticated users to auth
- Redirecting users with incomplete onboarding
- Sending fully onboarded users to the main tabs
Common Issues and Solutions
Issue: Navigation Not Working from Tabs
Problem: Callingnavigation.navigate() from inside tabs doesn’t work.
Solution: Use grandparent navigation:
Issue: Automatic Redirect Away from Screen
Problem: User gets redirected back to onboarding or tabs. Solution: Update redirect logic inuseAppNavigation.ts so the new route is
reachable for your target user state.
Issue: Wrong Back Button Text
Problem: Back button shows “(tabs)” or route name. Solution: Set custom back title:Best Practices
1. Consistent Screen Structure
- Use
ScreenContainerfor layout consistency - Follow the established padding/margin patterns
- Use theme colors via
useTheme()
2. Navigation Naming
- Use kebab-case for route names:
"feature-name" - Keep route names descriptive but concise
- Match file names to route names when possible
3. Header Configuration
- Always set meaningful
title - Use appropriate
presentationfor UX - Customize
headerBackTitlefor better navigation context
4. Navigation Guards
- Update redirect rules in
useAppNavigation.tswhen adding new flows - Consider authentication requirements
- Test navigation flows thoroughly
Example: Complete Feature Screen
Here’s a complete example following all best practices: File:apps/mobile/app/ai-chat.tsx
Troubleshooting
- Screen not accessible: check route group and auth/onboarding guards
- Header not updating: update the correct layout file