Skip to main content

Introduction to Expo Router

Expo Router is a file-based routing library for React Native and web applications. Built on top of React Navigation, it provides automatic route generation from file structure, deep linking, typed routes, and cross-platform navigation.

What is Expo Router?

Expo Router brings the simplicity of file-based routing to React Native, similar to what Next.js provides for web applications. Instead of manually configuring routes and navigation stacks, you simply create files in your app directory, and Expo Router automatically generates the navigation structure.

Key Features

File-Based Routing

Routes are automatically generated from your file structure. Create a file, get a route:

Universal Navigation

Works seamlessly across iOS, Android, and web with a single codebase. Deep links, URL parameters, and navigation work identically on all platforms.

Type-Safe Routes

Automatic TypeScript generation ensures type safety for all your routes and parameters:

Deep Linking Built-In

Every route is automatically deep linkable. No additional configuration needed:

Nested Layouts

Share UI across routes with nested layouts:
app/_layout.tsx

Benefits Over Traditional Navigation

Simplified Setup

Traditional React Navigation:
Expo Router:

Automatic Deep Linking

Traditional: Requires manual linking configuration with path patterns and parameter parsing. Expo Router: Every route is automatically deep linkable with the correct URL structure.

Type Safety

Traditional: String-based navigation with no type checking. Expo Router: Full TypeScript support with auto-generated types for routes and parameters.

Quick Example

Create a simple app with navigation:
app/index.tsx
app/about.tsx
app/profile/[id].tsx

Architecture Overview

Expo Router processes your file structure through a pipeline:
  1. Metro require.context() collects route files at build time
  2. getRoutes() converts file paths to a RouteNode tree
  3. getReactNavigationConfig() generates React Navigation configuration
  4. getLinkingConfig() creates deep linking configuration
  5. NavigationContainer receives the final configuration
This happens automatically - you just create files and components.

Next Steps

Installation

Install Expo Router and required dependencies

Quick Start

Build your first app with Expo Router

File-Based Routing

Learn how file structure maps to routes

Navigation

Navigate between screens