Mobile Development

React Native Navigation Patterns

Mayur Dabhi
Mayur Dabhi
May 25, 2026
14 min read

You add a Details screen, wire up a button, tap it, and the tab bar vanishes. Or the Android back button closes the app instead of going back one screen. Or you log out and can still swipe back into the account page. Almost every React Native app hits one of these early, and the cause is nearly always how the navigators are put together, not a bug in the screen.

On the web the browser gives you URLs and a back button for free. In React Native you have to describe the screen hierarchy yourself. This post walks through React Navigation 6: stack, tab and drawer navigators, how to nest them, passing params, an auth flow that can't be swiped around, and TypeScript types for routes.

Why React Navigation?

It's the library the React Native docs point you to, and it has a very large install base on npm. Version 6 brought a cleaner API, solid TypeScript support, and @react-navigation/native-stack, which uses the platform's own navigation primitives instead of animating everything in JavaScript.

Understanding React Navigation Architecture

The mental model is simple once it clicks. Every navigator keeps a navigation state, which is just a plain JavaScript object listing the mounted screens and which one is focused. When you call navigation.navigate('Details'), React Navigation updates this state, causing the correct screen component to render.

There are three pieces to keep in your head:

NavigationContainer Tab Navigator Stack Navigator Home Screen Details Screen Tab: Home Stack Navigator Search Screen Results Screen Tab: Search Single Screen Profile Screen Tab: Profile

Typical React Native navigation structure: Tab Navigator wrapping Stack Navigators

Installation and Setup

React Navigation ships as several packages, so you only pull in the navigators you use. The core package and its native dependencies are needed no matter what.

1

Install core dependencies

Install the main React Navigation package plus the native modules for screens and safe area support. On bare React Native, run npx pod-install afterwards and rebuild the app; a Metro reload isn't enough for new native code.

Terminal
# Core package and native dependencies
npm install @react-navigation/native

# Required peer dependencies
npm install react-native-screens react-native-safe-area-context

# For Expo projects, use:
npx expo install react-native-screens react-native-safe-area-context
2

Wrap your app in NavigationContainer

NavigationContainer manages the navigation tree and contains the navigation state. Put it once, at the top of your app.

App.js
import { NavigationContainer } from '@react-navigation/native';

export default function App() {
  return (
    <NavigationContainer>
      {/* Your navigators go here */}
    </NavigationContainer>
  );
}
3

Install your chosen navigator packages

Each navigator type is a separate package. Skip the ones you don't need.

Terminal: navigator packages
# Native Stack Navigator (recommended: uses native navigation primitives)
npm install @react-navigation/native-stack

# Bottom Tab Navigator
npm install @react-navigation/bottom-tabs

# Drawer Navigator
npm install @react-navigation/drawer
# Drawer also needs gesture handler and reanimated:
npm install react-native-gesture-handler react-native-reanimated
Native Stack vs JS Stack

Prefer @react-navigation/native-stack over @react-navigation/stack. The native stack uses platform-native navigation components (UINavigationController on iOS, Fragment on Android) so transitions and the Android back button behave the way users expect. The JS stack is still useful if you need fully custom transition animations.

Stack Navigator: Screens as a Pile

Picture a pile of cards. Each new screen goes on top, and going back takes the top one off. That's the whole idea, and it's the pattern you'll use most, usually inside other navigators.

Basic Stack Setup

navigation/AppStack.js
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomeScreen from '../screens/HomeScreen';
import DetailsScreen from '../screens/DetailsScreen';
import ProfileScreen from '../screens/ProfileScreen';

const Stack = createNativeStackNavigator();

export default function AppStack() {
  return (
    <Stack.Navigator
      initialRouteName="Home"
      screenOptions={{
        headerStyle: { backgroundColor: '#6c5ce7' },
        headerTintColor: '#fff',
        headerTitleStyle: { fontWeight: '700' },
      }}
    >
      <Stack.Screen
        name="Home"
        component={HomeScreen}
        options={{ title: 'My App' }}
      />
      <Stack.Screen
        name="Details"
        component={DetailsScreen}
        options={({ route }) => ({ title: route.params?.title ?? 'Details' })}
      />
      <Stack.Screen
        name="Profile"
        component={ProfileScreen}
        options={{ presentation: 'modal' }} // iOS modal presentation
      />
    </Stack.Navigator>
  );
}

Navigating Between Screens

Every screen registered in a navigator gets a navigation prop. You use it to push screens, replace the current one, or go back.

screens/HomeScreen.js
import { View, Text, Button, StyleSheet } from 'react-native';

export default function HomeScreen({ navigation }) {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>Welcome Home!</Text>

      {/* Push a new screen onto the stack */}
      <Button
        title="Go to Details"
        onPress={() => navigation.navigate('Details', { itemId: 42, title: 'Item 42' })}
      />

      {/* Replace the current screen (no back button) */}
      <Button
        title="Replace with Profile"
        onPress={() => navigation.replace('Profile')}
      />

      {/* Push always adds a new screen, even if it already exists in the stack */}
      <Button
        title="Push Details Again"
        onPress={() => navigation.push('Details', { itemId: 99, title: 'Item 99' })}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 },
  title: { fontSize: 24, fontWeight: '700' },
});
navigate vs push

navigation.navigate('Details') will go to an existing Details screen in the stack if one already exists (preventing duplicate screens). navigation.push('Details') always adds a fresh instance. Use navigate for standard flows and push when you explicitly need duplicate screens (e.g., a nested category explorer).

Tab Navigator: Parallel Screen Flows

Tabs fit top-level sections that carry roughly equal weight, like Feed, Search and Profile in a social app. Each tab keeps its own state, so switching tabs doesn't throw away your scroll position or the stack you'd drilled into.

Bottom Tab Navigator

navigation/MainTabs.js
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Ionicons } from '@expo/vector-icons'; // or react-native-vector-icons
import HomeStack from './HomeStack';
import SearchScreen from '../screens/SearchScreen';
import ProfileScreen from '../screens/ProfileScreen';

const Tab = createBottomTabNavigator();

export default function MainTabs() {
  return (
    <Tab.Navigator
      screenOptions={({ route }) => ({
        tabBarIcon: ({ focused, color, size }) => {
          const icons = {
            Home: focused ? 'home' : 'home-outline',
            Search: focused ? 'search' : 'search-outline',
            Profile: focused ? 'person' : 'person-outline',
          };
          return <Ionicons name={icons[route.name]} size={size} color={color} />;
        },
        tabBarActiveTintColor: '#6c5ce7',
        tabBarInactiveTintColor: '#888',
        tabBarStyle: {
          backgroundColor: '#111',
          borderTopColor: '#2a2a2a',
          paddingBottom: 4,
        },
        headerShown: false, // Each stack manages its own header
      })}
    >
      <Tab.Screen name="Home" component={HomeStack} />
      <Tab.Screen name="Search" component={SearchScreen} />
      <Tab.Screen
        name="Profile"
        component={ProfileScreen}
        options={{
          tabBarBadge: 3, // Show notification badge
        }}
      />
    </Tab.Navigator>
  );
}

Tab Navigator Comparison

Feature Bottom Tabs Material Top Tabs Material Bottom Tabs
Position Bottom of screen Top (below header) Bottom of screen
Swipe between tabs No Yes (ViewPager) No
Best for iOS-style apps, main nav Content categories, settings Material Design apps
Package @react-navigation/bottom-tabs @react-navigation/material-top-tabs @react-navigation/material-bottom-tabs
Lazy loading Yes (default) Configurable Yes (default)

Drawer Navigator: Side Menu Patterns

A drawer slides a menu in from the side. Reach for it when you have more top-level destinations than fit in a tab bar, or for secondary stuff like settings and account pages.

Basic Drawer Setup

navigation/AppDrawer.js
import { createDrawerNavigator } from '@react-navigation/drawer';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import HomeScreen from '../screens/HomeScreen';
import SettingsScreen from '../screens/SettingsScreen';
import HelpScreen from '../screens/HelpScreen';

const Drawer = createDrawerNavigator();

export default function AppDrawer() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Drawer.Navigator
        initialRouteName="Home"
        screenOptions={{
          drawerStyle: { backgroundColor: '#111', width: 280 },
          drawerActiveTintColor: '#6c5ce7',
          drawerInactiveTintColor: '#888',
          drawerLabelStyle: { fontSize: 15 },
          headerStyle: { backgroundColor: '#111' },
          headerTintColor: '#fff',
        }}
      >
        <Drawer.Screen
          name="Home"
          component={HomeScreen}
          options={{ drawerIcon: ({ color }) => <Ionicons name="home" color={color} size={22} /> }}
        />
        <Drawer.Screen
          name="Settings"
          component={SettingsScreen}
          options={{ drawerIcon: ({ color }) => <Ionicons name="settings" color={color} size={22} /> }}
        />
        <Drawer.Screen
          name="Help"
          component={HelpScreen}
          options={{ drawerIcon: ({ color }) => <Ionicons name="help-circle" color={color} size={22} /> }}
        />
      </Drawer.Navigator>
    </GestureHandlerRootView>
  );
}

Custom Drawer Content

If the default list of items isn't enough (say you want a profile header and a logout button), pass your own component to the drawerContent prop.

navigation/CustomDrawer.js
import { View, Text, Image, TouchableOpacity, StyleSheet } from 'react-native';
import { DrawerContentScrollView, DrawerItemList } from '@react-navigation/drawer';

export default function CustomDrawer(props) {
  return (
    <DrawerContentScrollView {...props} contentContainerStyle={styles.container}>
      {/* User profile section */}
      <View style={styles.profileSection}>
        <Image
          source={{ uri: 'https://example.com/avatar.jpg' }}
          style={styles.avatar}
        />
        <Text style={styles.name}>Mayur Dabhi</Text>
        <Text style={styles.email}>mayurdabhi.6@gmail.com</Text>
      </View>

      {/* Default drawer items */}
      <DrawerItemList {...props} />

      {/* Custom footer item */}
      <TouchableOpacity
        style={styles.logoutBtn}
        onPress={() => console.log('Logout')}
      >
        <Text style={styles.logoutText}>Log Out</Text>
      </TouchableOpacity>
    </DrawerContentScrollView>
  );
}

// In your Drawer.Navigator:
// <Drawer.Navigator drawerContent={(props) => <CustomDrawer {...props} />}>
GestureHandlerRootView is Required

The Drawer Navigator requires react-native-gesture-handler. You must wrap your root component in <GestureHandlerRootView style={{ flex: 1 }}>. Without it, swipe-to-open often just doesn't work, with no obvious error. Also, if the app throws a Reanimated error the first time a drawer screen loads, check that react-native-reanimated/plugin is the last entry in your babel.config.js plugins, then restart Metro with --reset-cache.

Nesting Navigators

Real apps rarely stick to one navigator. The most common layout is tabs containing stacks: each tab gets its own stack, so users can drill into content without losing the tab bar. If your tab bar disappears when you open a detail screen, you've probably done it the other way round and put the tabs inside a stack.

Tab + Stack Pattern

navigation/HomeStack.js
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomeScreen from '../screens/HomeScreen';
import ArticleScreen from '../screens/ArticleScreen';
import CommentsScreen from '../screens/CommentsScreen';

const Stack = createNativeStackNavigator();

// Each tab gets its own stack navigator
export default function HomeStack() {
  return (
    <Stack.Navigator screenOptions={{ headerShown: false }}>
      <Stack.Screen name="HomeMain" component={HomeScreen} />
      <Stack.Screen name="Article" component={ArticleScreen} />
      <Stack.Screen name="Comments" component={CommentsScreen} />
    </Stack.Navigator>
  );
}

// Then in MainTabs:
// <Tab.Screen name="Home" component={HomeStack} />

Navigating Across Navigators

Navigating to a screen in a sibling tab's stack means naming the parent navigator first, then the screen inside it via the screen key.

Cross-navigator navigation
// Navigate to a screen in a different tab's stack:
navigation.navigate('ProfileTab', {
  screen: 'EditProfile',
  params: { userId: 123 },
});

// Navigate back to the root of the current stack:
navigation.popToTop();

// Navigate to a specific screen anywhere in the tree:
navigation.navigate('Root', {
  screen: 'Home',
  params: {
    screen: 'Article',
    params: { articleId: 42 },
  },
});

// Reset the entire navigation state (e.g., after logout):
import { CommonActions } from '@react-navigation/native';

navigation.dispatch(
  CommonActions.reset({
    index: 0,
    routes: [{ name: 'Login' }],
  })
);

Passing Params Between Screens

Params ride along with the route, and the receiving screen reads them from route.params. Keep them small: an ID is better than a whole object you'll have to keep in sync.

Sending and Receiving Params

Params: send and receive
// --- SENDING PARAMS ---
// Pass an object as the second argument to navigate()
navigation.navigate('ProductDetails', {
  productId: 'prod-123',
  productName: 'Wireless Headphones',
  price: 79.99,
});

// --- RECEIVING PARAMS ---
export default function ProductDetailsScreen({ route, navigation }) {
  const { productId, productName, price } = route.params;

  return (
    <View>
      <Text>{productName}</Text>
      <Text>${price}</Text>
      <Button
        title="Add to Cart"
        onPress={() => {
          // Send data BACK to the previous screen
          navigation.navigate('Cart', { addedItem: productId });
        }}
      />
    </View>
  );
}

// --- UPDATING PARAMS (useful for forms passing back data) ---
navigation.setParams({ price: 69.99 }); // Updates the current screen's params

// --- DEFAULT PARAMS ---
// Set fallback values in initialParams to avoid undefined errors:
<Stack.Screen
  name="ProductDetails"
  component={ProductDetailsScreen}
  initialParams={{ price: 0, productName: 'Unknown Product' }}
/>

Using useNavigation and useRoute Hooks

If you need navigation or route access deep inside a component tree (not at the screen level), use the hooks instead of prop drilling.

Hooks for deep components
import { useNavigation, useRoute } from '@react-navigation/native';

// Works in ANY component inside NavigationContainer, no prop drilling
export default function ProductCard({ product }) {
  const navigation = useNavigation();
  const route = useRoute(); // Current screen's route info

  return (
    <TouchableOpacity
      onPress={() => navigation.navigate('ProductDetails', { productId: product.id })}
    >
      <Text>{product.name}</Text>
    </TouchableOpacity>
  );
}

// Listen for focus / blur events (e.g., refresh data when returning to a screen)
import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';

export default function HomeScreen() {
  useFocusEffect(
    useCallback(() => {
      fetchLatestData(); // Runs every time this screen comes into focus
      return () => {
        // Optional cleanup when screen blurs
      };
    }, [])
  );
}

Best Practices and Common Patterns

These are the patterns I keep coming back to. The table is a quick map of which navigator suits which job.

Navigation Patterns Quick Reference

Pattern Use Case Navigator
Auth Flow Guard Show login/register before main app Conditional Stack render
Modal Screen Image viewer, confirmation dialogs Stack with presentation: 'modal'
Tab + Stack Most social/e-commerce apps BottomTabs wrapping Stacks
Drawer + Stack Admin panels, content-heavy apps Drawer wrapping Stacks
Deep Linking Push notifications, URLs to screens NavigationContainer linking prop
Splash / Onboarding First-launch flow Stack with animationTypeForReplace

Authentication Flow Pattern

Don't navigate to Login on logout. Render a different set of screens based on auth state instead. When user changes, React Navigation swaps the tree, and the old screens are gone, so there's nothing to swipe back into.

App.js: Auth Flow
import { NavigationContainer } from '@react-navigation/native';
import { useAuth } from './hooks/useAuth'; // Your auth context
import AuthStack from './navigation/AuthStack'; // Login, Register, ForgotPassword
import MainTabs from './navigation/MainTabs';   // Authenticated app
import SplashScreen from './screens/SplashScreen';

export default function App() {
  const { user, isLoading } = useAuth();

  if (isLoading) {
    return <SplashScreen />;
  }

  return (
    <NavigationContainer>
      {/* React Navigation will animate between these on auth state change */}
      {user ? <MainTabs /> : <AuthStack />}
    </NavigationContainer>
  );
}

TypeScript Support

Define a param list per navigator and the compiler will tell you when you navigate to a screen that doesn't exist or forget a required param. It's a few minutes of setup.

navigation/types.ts
import { NativeStackScreenProps } from '@react-navigation/native-stack';

// Define the param list for each screen
export type RootStackParamList = {
  Home: undefined;                        // No params
  Details: { itemId: number; title: string }; // Required params
  Profile: { userId?: string };           // Optional param
  Modal: undefined;
};

// Typed screen props: use this instead of any
export type DetailsScreenProps = NativeStackScreenProps<
  RootStackParamList,
  'Details'
>;

// In your screen component:
export default function DetailsScreen({ route, navigation }: DetailsScreenProps) {
  // route.params.itemId is correctly typed as number
  const { itemId, title } = route.params;
  // ...
}

// Register the param list with the navigator for global type safety:
declare global {
  namespace ReactNavigation {
    interface RootParamList extends RootStackParamList {}
  }
}

Mistakes I see most often

  • A second NavigationContainer inside a screen. You'll get a warning about nesting containers, and the inner tree won't know about the outer one. Use one container at the root, always.
  • Functions or class instances in params. React Navigation warns about non-serializable values because they break deep linking and state persistence. Pass an ID and look the data up, or use context or a store for callbacks.
  • useEffect for "refresh when I come back". Screens in a stack stay mounted, so the effect won't run again. That's what useFocusEffect is for.
  • Calling navigate('Login') on logout instead of switching screens on auth state. The authenticated screens stay in history and the user can get back to them.
  • Nesting for the sake of it. Every extra navigator adds a level to your navigate calls, your deep link config and your types.

When I'd use each navigator (and when I wouldn't)

I start almost every app with bottom tabs wrapping native stacks. It matches what users already know from iOS and Android, and it's easy to deep link into. I'd add a drawer only when there are clearly more than four or five top-level sections, because items hidden behind a hamburger icon get used less than ones sitting in a tab bar. Material top tabs suit swipeable categories inside one section, not your main navigation.

I wouldn't pick React Navigation on autopilot if you're starting a new Expo project and want file-based routing. Expo Router is built on top of React Navigation and gives you URL-style routes and deep links with less config. And if your app is really two or three screens, a single native stack is plenty. You can always restructure later, though changing the tree does mean updating every nested navigate call, so it's worth sketching the hierarchy before you've got thirty screens.

React Native Navigation Mobile React Navigation Stack Navigator Tab Navigator
Mayur Dabhi

Mayur Dabhi

Full Stack Developer with 5+ years of experience building scalable web applications with Laravel, React, and Node.js.