Skip to main content
Version: 7.x

Getting started

What follows within the Fundamentals section of this documentation is a tour of the most important aspects of React Navigation. It should cover enough for you to know how to build your typical small mobile application, and give you the background that you need to dive deeper into the more advanced parts of React Navigation.

Pre-requisites

If you're already familiar with JavaScript, React and React Native, then you'll be able to get moving with React Navigation quickly! If not, we highly recommend you to gain some basic knowledge first, then come back here when you're done.

Here are some resources to help you out:

  1. Main Concepts of React
  2. Getting started with React Native
  3. React Hooks
  4. React Context

Minimum requirements

  • react-native >= 0.72.0
  • expo >= 52 (if you use Expo Go)
  • typescript >= 5.0.0 (if you use TypeScript)

Starter template

If you're starting a new project, you can use the React Navigation template to quickly set up a new project with Static configuration:

npx create-expo-app@latest --template react-navigation/template

See the project's README.md for more information on how to get started.

If you created a new project using the template, you can skip the installation steps below and move on to "Hello React Navigation".

Otherwise, you can follow the instructions below to install React Navigation into your existing project.

Installation

The @react-navigation/native package contains the core functionality of React Navigation.

In your project directory, run:

npm install @react-navigation/native

Installing dependencies

Let's also install and configure dependencies used by most navigators. The libraries we will install now are react-native-screens and react-native-safe-area-context.

In your project directory, run:

npx expo install react-native-screens react-native-safe-area-context

This will install versions of these libraries that are compatible with your Expo SDK version.

Setting up React Navigation

Once you've installed and configured the dependencies, you can move on to setting up your project to use React Navigation.

When using React Navigation, you configure navigators in your app. Navigators handle the transition between screens in your app and provide UI such as header, tab bar etc.

info

When you use a navigator (such as stack navigator), you'll need to follow the installation instructions of that navigator for any additional dependencies.

There are 2 primary ways to configure the navigators:

Static configuration

The static configuration API lets you write your configuration in an object, and is defined statically, though some aspects of the configuration can still can be changed dynamically. This has reduced boilerplate and simplifies things such as TypeScript types and deep linking.

If you're starting a new project or are new to React Navigation, this is the recommended way to set up your app. If you need more flexibility in the future, you can always mix and match with the dynamic configuration.

Continue to "Hello React Navigation" to start writing some code with the static API.

Dynamic configuration

The dynamic configuration API lets you write your configuration in React components, and can change at runtime based on state or props. This allows for more flexibility but requires significantly more boilerplate and configuration for Typescript types, deep linking etc.

Continue to "Hello React Navigation" to start writing some code with the dynamic API.