File-based routing overview
Expo Router automatically turns files in theapp/ directory into screens (not pages!):
app/_layout.tsxdefines a rootStacknavigator that wraps the whole app and currently registers the(tabs)group as a stack screen.app/(tabs)/_layout.tsxdefines theTab navigator, with individual tabs likehomeandsettingsmapped to files in the same folder.app/(tabs)/home.tsxandapp/(tabs)/settings.tsxare the screens shown inside those tab routes.
Every project should have aIf you are familliar with Next.js, you might have noticed similarities, well that is because both Routers basically use the same file-based routing mechanism._layout.tsxfile directly inside thesrc/appdirectory. This file is rendered before any other route in your app and is where you would put the initialization code that may have previously gone inside anApp.jsxfile, such as loading fonts, setting up theme providers, or interacting with the splash screen. For example, the default template wraps the app with aThemeProviderfor dark and light mode support and renders theAppTabscomponent from this file.
From: https://docs.expo.dev/router/basics/core-concepts
Root stack layout
The root layout wraps the app in navigation theming and sets up a stack navigator:app/_layout.tsx (simplified)
(tabs), which renders the tab navigator and shows a shared header with the title and the theme toggle. It is also common pracitce to keep non-navigation components outside the src/app directory, like in the @/components/ directory.
Tabs layout: native tabs + cross‑platform fallback
The template uses native tabs on iOS and standard bottom tabs for other platforms:app/(tabs)/_layout.tsx (simplified)
- On iOS,
NativeTabsrenders a platform-native tab bar with SF Symbols icons. - On Android / web, the regular
Tabslayout from Expo Router is used with Ionicons.
The file names
home.tsx and settings.tsx must match the name values used in the tabs layout for routing to work automatically.Task 2: Screens
Create a new screen (let’s call it thedetail screen) that is pushed onto the stack from the Home tab:
1
Create the details Screen
app/details.tsx
2
Add navigation to details from Home
In
app/(tabs)/home.tsx, add a button that navigates to /details- In React Native the
onClickfunction is calledonPress. - You can use the
routerobject from (expo-router) to navigate. (.push('<path>'))
3
Create another Screen and add it as a Tab
Optional
Now add another screen called
profile and add it between the Home and Settings tab.