Navigation (React Navigation) — Mobile

A stack piles screens up (push to open, pop to go back), tabs switch between main screens without stacking. React Navigation 7 is React Native's most…

An app on a phone has no address bar. On the web, moving between pages is a matter of URLs and the browser's back button. In an app, screens are stacked like cards, tabs sit at the bottom, and going back works differently on Android and iOS. All of that is navigation: how people move between screens. Look at Mrs. Rini's counter. On top of the order list you put receipt #13 to read it (push). When you're done, you take that top receipt off again (pop), and the list is still underneath, exactly where it was. The same counter has two drawers, Orders and Account. Switching drawers stacks nothing. The pile of receipts is a stack, the drawers are tabs.

Stack and tabs

Mrs. Rini's app uses both: a stack on the outside, holding the tabs (Orders and Account) and the order detail screen. The navigation state is kept as a plain object. After order #13 is opened:

{ index: 1, routes: [
  { name: 'Tabs', state: { index: 0, routes: [{ name: 'Orders' }, { name: 'Account' }] } },
  { name: 'OrderDetail', params: { id: '13' } },
] }

React Navigation 7

React Navigation is React Native's most established navigation library: up to Expo Router 55, even Expo Router was built on top of it. On npm, 2 to 8 October 2026, @react-navigation/native was downloaded 5.98 million times and expo-router 7.29 million times (downloads, not a count of apps). Its stable version is 7 (@react-navigation/native 7.5.0 as of October 2026), and version 8 is still in alpha. In an Expo project without Expo Router (npx create-expo-app@latest --template blank):

npm install @react-navigation/native @react-navigation/native-stack @react-navigation/bottom-tabs
npx expo install react-native-screens react-native-safe-area-context

Its docs recommend the static API: navigators written as objects.

// App.js
import { createStaticNavigation, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Pressable, Text, View } from 'react-native';
import { ORDERS } from './src/data/orders';

function OrdersScreen() {
  const navigation = useNavigation();
  return (
    <View>
      {ORDERS.map((order) => (
        <Pressable key={order.id} onPress={() => navigation.navigate('OrderDetail', { id: order.id })}>
          <Text>#{order.id} {order.name}</Text>
        </Pressable>
      ))}
    </View>
  );
}

function OrderDetailScreen({ route }) {
  const order = ORDERS.find((o) => o.id === route.params.id);
  return <Text>{order.name}: {order.status}</Text>;
}

const AccountScreen = () => <Text>Account</Text>;

const Tabs = createBottomTabNavigator({
  screens: {
    Orders: { screen: OrdersScreen, options: { title: 'My orders', tabBarLabel: 'Orders' } },
    Account: AccountScreen,
  },
});

const RootStack = createNativeStackNavigator({
  screens: {
    Tabs: { screen: Tabs, options: { headerShown: false } },
    OrderDetail: {
      screen: OrderDetailScreen,
      options: ({ route }) => ({ title: `Order #${route.params.id}` }),
    },
  },
});

const Navigation = createStaticNavigation(RootStack);

export default function App() {
  return <Navigation />;
}

Expo Router: screens from file names

The project from the setup lesson uses Expo Router, which builds routes from the files in src/app. Its version is 57, following the SDK's number. Since version 56 (May 2026), Expo Router no longer depends on React Navigation: it forked the parts it used, and imports from @react-navigation/* in app code are no longer supported. Import from expo-router.

src/app/
├── _layout.tsx        # Stack
├── (tabs)/
│   ├── _layout.tsx    # Tabs: Orders and Account
│   ├── index.tsx      # /          the order list
│   └── account.tsx    # /account
└── order/
    └── [id].tsx       # /order/13  the order detail
// src/app/order/[id].tsx
import { Stack, useLocalSearchParams } from 'expo-router';
import { Text, View } from 'react-native';
import { ORDERS } from '@/data/orders';

export default function OrderDetail() {
  const { id } = useLocalSearchParams<{ id: string }>();
  const order = ORDERS.find((o) => o.id === id);

  return (
    <View>
      <Stack.Screen options={{ title: `Order #${id}` }} />
      <Text>{order ? `${order.name}: ${order.status}` : 'Order not found'}</Text>
    </View>
  );
}

Back on Android and iOS

Guess first: Wulan opens the app on an Android phone, taps order #13, then presses Android's back twice. What happens on the second press?

Action Stack What shows
Open the app Tabs My orders
Tap #13 Tabs, OrderDetail { id: '13' } Order #13
Android back Tabs My orders
Android back nothing left to pop leaves to the home screen

So the second press sends the app to the home screen.

⚠️ Params, push and imports that often go wrong

TL;DR: A stack piles screens up (push to open, pop to go back), tabs switch between main screens without stacking. React Navigation 7 is React Native's most established navigation library, and its docs recommend the static API (createNativeStackNavigator({ screens }), createStaticNavigation). Keep params minimal: navigation.navigate('OrderDetail', { id: '13' }), read from route.params.id. Expo Router 57 builds routes from files: src/app/order/[id].tsx is /order/13, read with useLocalSearchParams(), and since version 56 it no longer depends on React Navigation. iOS goes back through the header or a swipe from the left edge. Android has a system back, and on the first screen back sends the app to the home screen.

⚡ A pile and drawers

Meaning: A stack piles screens up: opening a new screen pushes it on top, going back pops it off the top. Tabs switch between main screens, such as Orders and Account, without stacking anything, and each tab keeps its own state. Mrs. Rini's app uses both: a stack on the outside, holding the tabs and the order detail screen.

⚡ Send only the id

Write:

navigation.navigate('OrderDetail', { id: order.id });

// in OrderDetailScreen
const order = ORDERS.find((o) => o.id === route.params.id);

Meaning: For order #13, route.params holds { id: '13' }. The full data is looked up in ORDERS, so there's no copy that can go stale when its status changes.

⚡ Back on Android

Guess first: Wulan opens order #13 on an Android phone, then presses back twice. What happens on the second press?

The app leaves to the home screen. The first press pops OrderDetail, and on the first screen there's nothing left to pop, so the back press goes to Android.

Meaning: iOS has no system back button: you go back with the button at the top left of the header, or by swiping from the left edge of the screen. On the first screen, the app stays open.

What you will learn