Mobile development · Intermediate · 18 min
How to Add Navigation to an Expo App with Expo Router
By Padding · Updated 15 Nov 2026
Expo SDK 58 · Expo Router 58
You will turn an Expo SDK 58 app into a multi-screen app with Expo Router, using files as routes, a bottom tab bar, a stack of detail screens opened from a list, a dynamic route that reads its parameter, links and navigation from code, and a not-found screen.
On this page
Most apps have more than one screen, and moving between them has rules: tabs stay in place while a detail screen slides over them, the back button returns where you came from, and a link from outside the app should open the right screen. Expo Router handles this with a simple idea. Every file in the src/app folder is a route, and its name is its address, as on a website. The same routes work on iOS, Android and the web.
This tutorial changes the project from the first tutorial into a small notes app with three kinds of navigation: tabs at the bottom, a list that opens a detail screen, and a screen whose content depends on a value in its address. You write every file yourself, so you see how each part fits.
Step 1 · Plan the routes
Files under src/app become routes. A folder name in parentheses, such as (tabs), is a group: it organises files and shares a layout without adding anything to the address. A name in square brackets, such as [id].tsx, is a dynamic segment that matches any value. The app you will build looks like this:
| File | Address | Shows |
|---|---|---|
| src/app/_layout.tsx | none | the root stack that holds everything |
| src/app/(tabs)/_layout.tsx | none | the bottom tab bar |
| src/app/(tabs)/index.tsx | / | the list of notes (first tab) |
| src/app/(tabs)/about.tsx | /about | an about screen (second tab) |
| src/app/note/[id].tsx | /note/1, /note/2 | one note |
| src/app/+not-found.tsx | any unknown address | a friendly error |
A _layout.tsx file does not render a screen. It decides how its folder's screens are arranged: as a stack, as tabs, or in another container.
Step 2 · Clear out the template's screens
The template has its own index.tsx and explore.tsx, which would clash with the files you are about to write. Both src/app/index.tsx and src/app/(tabs)/index.tsx would claim the address /. Remove the template's two screens now. The next step replaces its root layout. The template's src/components folder stays, and the new screens do not use it. This deletes your counter screen from the previous tutorial, so copy it elsewhere first if you want to keep it:
cd ~/expo-demo/hello-expo
rm src/app/index.tsx src/app/explore.tsx
mkdir -p "src/app/(tabs)" "src/app/note"
ls src/appThe listing shows (tabs), _layout.tsx and note.
Step 3 · Write the root stack
The root layout holds a Stack. A stack keeps screens in a pile: opening one puts it on top, and going back removes it. Replace src/app/_layout.tsx. The quoted heredoc keeps the parentheses and brackets safe from the shell:
cat > src/app/_layout.tsx <<'TSX'
import { Stack } from 'expo-router'
export default function RootLayout() {
return (
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="note/[id]" options={{ title: 'Note' }} />
</Stack>
)
}
TSXThe (tabs) group draws its own header, so the stack hides its own for that screen. The note screen uses the stack's header, which brings a back button without any code. name is the file path under src/app without the extension.
Step 4 · Add the tabs
A Tabs layout shows a bar of buttons at the bottom, one for each screen file in its folder. Create src/app/(tabs)/_layout.tsx:
cat > "src/app/(tabs)/_layout.tsx" <<'TSX'
import { Tabs } from 'expo-router'
export default function TabLayout() {
return (
<Tabs>
<Tabs.Screen name="index" options={{ title: 'Notes' }} />
<Tabs.Screen name="about" options={{ title: 'About' }} />
</Tabs>
)
}
TSXtitle is the label in the tab bar and the text in the header. Now the two screens. The first is shared data. Put the notes in their own file, so that the list and the detail screen read the same source. A real app would load them from storage or a server:
cat > src/notes.ts <<'TS'
export type Note = { id: string; title: string; body: string }
export const notes: Note[] = [
{ id: '1', title: 'Buy milk', body: 'Two litres, semi-skimmed.' },
{ id: '2', title: 'Plan the trip', body: 'Check the train times for Friday.' },
{ id: '3', title: 'Call the dentist', body: 'Ask about the next free appointment.' },
]
export function findNote(id: string | undefined): Note | undefined {
return notes.find((note) => note.id === id)
}
TSThe About tab is plain:
cat > "src/app/(tabs)/about.tsx" <<'TSX'
import { StyleSheet, Text, View } from 'react-native'
export default function AboutScreen() {
return (
<View style={styles.container}>
<Text style={styles.title}>About</Text>
<Text>A small notes app built with Expo Router.</Text>
</View>
)
}
const styles = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 8, padding: 24 },
title: { fontSize: 24, fontWeight: '700' },
})
TSXStep 5 · Link from a list to a detail screen
The first tab lists the notes. Link is Expo Router's navigation component: it renders a pressable that moves to another route. asChild passes the link behaviour to the Pressable inside, so you control how it looks:
cat > "src/app/(tabs)/index.tsx" <<'TSX'
import { Link } from 'expo-router'
import { FlatList, Pressable, StyleSheet, Text } from 'react-native'
import { notes } from '@/notes'
export default function NotesScreen() {
return (
<FlatList
data={notes}
keyExtractor={(note) => note.id}
contentContainerStyle={styles.list}
renderItem={({ item }) => (
<Link href={{ pathname: '/note/[id]', params: { id: item.id } }} asChild>
<Pressable accessibilityRole="link" style={styles.row}>
<Text style={styles.rowText}>{item.title}</Text>
</Pressable>
</Link>
)}
/>
)
}
const styles = StyleSheet.create({
list: { padding: 16, gap: 8 },
row: { padding: 16, borderRadius: 12, backgroundColor: '#eef4ff' },
rowText: { fontSize: 18 },
})
TSXThe href is an object with the route pattern and its parameters. Expo Router fills [id] for you, and with typed routes (turned on in this template's app.json) your editor checks that the pattern exists. The @/ in the import is a path alias for src/, which the template configures in tsconfig.json. FlatList renders only the rows on screen, which is the right list component for anything that can grow.
Step 6 · Read a parameter in a dynamic route
The file src/app/note/[id].tsx matches /note/1, /note/2 and anything else. Inside it, useLocalSearchParams returns the parameters for this route. Always handle a value that does not match a note, because addresses can come from links outside the app:
cat > "src/app/note/[id].tsx" <<'TSX'
import { Stack, useLocalSearchParams, useRouter } from 'expo-router'
import { Pressable, StyleSheet, Text, View } from 'react-native'
import { findNote } from '@/notes'
export default function NoteScreen() {
const { id } = useLocalSearchParams<{ id: string }>()
const router = useRouter()
const note = findNote(id)
if (!note) {
return (
<View style={styles.container}>
<Stack.Screen options={{ title: 'Not found' }} />
<Text style={styles.title}>There is no note {id}.</Text>
<Pressable accessibilityRole="button" onPress={() => router.replace('/')}>
<Text style={styles.action}>Back to the list</Text>
</Pressable>
</View>
)
}
return (
<View style={styles.container}>
<Stack.Screen options={{ title: note.title }} />
<Text style={styles.title}>{note.title}</Text>
<Text style={styles.body}>{note.body}</Text>
<Pressable accessibilityRole="button" onPress={() => router.back()}>
<Text style={styles.action}>Done</Text>
</Pressable>
</View>
)
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 24, gap: 12 },
title: { fontSize: 24, fontWeight: '700' },
body: { fontSize: 18 },
action: { fontSize: 16, color: '#208AEF', paddingVertical: 8 },
})
TSXThree details. Stack.Screen inside a screen sets that screen's header options, which is how the title follows the note. router.back() goes to the previous screen, and router.replace('/') swaps the current screen for another so that the back button does not return to the error. router.push('/note/2') is the other call you will use: it opens a screen from code instead of a link, for example after a form is saved. Use useLocalSearchParams for the current route's parameters. A sibling hook, useGlobalSearchParams, also changes when other screens in the stack change, and is rarely what you want.
Step 7 · Add a not-found screen
When the address matches no file, Expo Router renders +not-found.tsx if it exists. This happens for a mistyped deep link as well as for the web:
cat > "src/app/+not-found.tsx" <<'TSX'
import { Link, Stack } from 'expo-router'
import { StyleSheet, Text, View } from 'react-native'
export default function NotFoundScreen() {
return (
<View style={styles.container}>
<Stack.Screen options={{ title: 'Not found' }} />
<Text style={styles.title}>This screen does not exist.</Text>
<Link href="/" style={styles.link}>
Go to the notes
</Link>
</View>
)
}
const styles = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 12, padding: 24 },
title: { fontSize: 20, fontWeight: '600' },
link: { fontSize: 16, color: '#208AEF' },
})
TSXStep 8 · Run it and try each kind of navigation
Start the development server and open the app, as in the first tutorial:
cd ~/expo-demo/hello-expo
npx expo startTry these: tap the two tabs, tap a note to open its screen, use the header's back button (or swipe from the left edge on iOS), and in the web version, press w, and visit /note/2 and /note/99 directly in the address bar. The first shows the second note and the second shows the "There is no note 99" text. Opening a screen by its address is a deep link, and it is also how the web version works. To test a deep link while you use Expo Go, use Expo's helper with the exp:// address that Expo Go uses. The /--/ separates the server address from the path inside your app. The address is the one the terminal shows under the QR code; on a simulator it is 127.0.0.1:8081, and on a phone it is your computer's address on the Wi-Fi network:
npx uri-scheme open exp://127.0.0.1:8081/--/note/2 --iosReplace --ios with --android for an Android emulator. The myapp:// scheme in app.json does not work in Expo Go. After you add or change a custom scheme, you need a new development build, as Expo's linking documentation says (docs.expo.dev/linking/into-your-app/).
Check it worked
Without a device, check that every screen bundles and every route is found. The export builds the web version of the app:
cd ~/expo-demo/hello-expo
npx expo export --platform webThe output lists a bundle for each screen file, including about and [id], and ends with Exported: dist. If a screen file has a mistake, such as an import that does not exist, the export stops and names it.
Troubleshooting
Unmatched Routeon screen: the address has no file. Check the spelling and that the file lives undersrc/app. A file insrc/componentsis not a route.- Two screens claim the same address, and Expo Router warns about it: you have both
src/app/index.tsxandsrc/app/(tabs)/index.tsx. Delete one. - The tab bar does not appear: the screens have to be in the folder whose
_layout.tsxreturnsTabs. Check thenamevalues match the file names. - A new route is missing after you add a file: press
rin the terminal to reload, or restart withnpx expo start --clear. - A typed
hrefis flagged as an error although the file exists: the route types are regenerated while the dev server runs. Start the server once, and the editor catches up.
Step 9 · Clean up
Press Ctrl+C in the terminal that runs expo start. Delete the practice project, unless you want to keep it for the build tutorial:
cd ~
rm -rf ~/expo-demoNext steps
- Build the app for real devices and the stores: build and submit an Expo app with EAS.
- Start from the basics again: create your first React Native app with Expo.
- Compare with web routing in React: build a Next.js 16 App Router site.
Related tutorials
- How to Set Up a TypeScript 7 Project from ScratchYou will create a Node.js 26 project, install TypeScript 7, write a tsconfig.json you understand, compile two files to JavaScript, watch the compiler catch a type error, and add npm scripts for building, checking and running.
- How to Build a React 19 App with ViteYou will scaffold a React 19 and TypeScript app with Vite 8, run the dev server, replace the starter page with a small checklist built from components and state, then create a production build and serve it locally.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials