Router

_layout.tsx

Root _layout.tsx replaces App.jsx/tsx.

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 an App.jsx file, such as loading fonts or interacting with the splash screen.

Every file is a route in app

app directory is exclusively for defining your app's routes.

Using Router

import { router, useRouter } from "expo-router"; const router = useRouter(); const logIn = () => { setIsLoggedIn(true); router.replace('/'); } const logOut = () => { setIsLoggedIn(false); router.replace('/login'); }

Navigation

Expo Router defaults to stack navigation.

Navigating to a new route pushes a screen onto a stack.

  • backing out of the route pops it off the stack.