What is Expo Router?
What is Expo Router?
Expo Router vs React Navigation
Expo Router provides file-based routing for applications built with Expo, supporting both React Native and the web
Expo Router provides file-based routing for applications built with Expo, supporting both React Native and the web
It's created to introduce the most effective file-system routing ideas from the web to cross-platform apps on Android, iOS, and the web
When working with React Native, handling navigation can be one of the biggest challenges
When working with React Native, handling navigation can be one of the biggest challenges
React Native developers have traditionally depended on tools like React Navigation, which required manual configuration of navigators, screens, and routes
When working with React Native, handling navigation can be one of the biggest challenges
React Native developers have traditionally depended on tools like React Navigation, which required manual configuration of navigators, screens, and routes
As your application grows, this can quickly become complex and hard to maintain
When working with React Native, handling navigation can be one of the biggest challenges
React Native developers have traditionally depended on tools like React Navigation, which required manual configuration of navigators, screens, and routes
As your application grows, this can quickly become complex and hard to maintain
Expo Router streamlines the whole process by adopting a file-based approach
The way you organise your files and folders directly shapes your app’s navigation structure
The way you organise your files and folders directly shapes your app’s navigation structure
Expo Router apps are designed to cache and run offline-first, updating automatically when a new version is published
The way you organise your files and folders directly shapes your app’s navigation structure
Expo Router apps are designed to cache and run offline-first, updating automatically when a new version is published
Your app can process incoming native URLs without needing a network connection or server
The way you organise your files and folders directly shapes your app’s navigation structure
Expo Router apps are designed to cache and run offline-first, updating automatically when a new version is published
Your app can process incoming native URLs without needing a network connection or server
Expo Router is built on top of React Navigation
The way you organise your files and folders directly shapes your app’s navigation structure
Expo Router apps are designed to cache and run offline-first, updating automatically when a new version is published
Your app can process incoming native URLs without needing a network connection or server
Expo Router is built on top of React Navigation
It's not a full replacement, but an enhancement that makes navigation with more option and easier to manage
Simplicity
Simplicity
With React Navigation, you must manually define and set up each navigator, screen, and route, which requires a lot of boilerplate code
Simplicity
With React Navigation, you must manually define and set up each navigator, screen, and route, which requires a lot of boilerplate code
Expo Router eliminates this by automatically generating routes based on your file structure
Simplicity
With React Navigation, you must manually define and set up each navigator, screen, and route, which requires a lot of boilerplate code
Expo Router eliminates this by automatically generating routes based on your file structure
Maintainability
Simplicity
With React Navigation, you must manually define and set up each navigator, screen, and route, which requires a lot of boilerplate code
Expo Router eliminates this by automatically generating routes based on your file structure
Maintainability
As your app expands, managing navigation with React Navigation can become more complicated
Simplicity
With React Navigation, you must manually define and set up each navigator, screen, and route, which requires a lot of boilerplate code
Expo Router eliminates this by automatically generating routes based on your file structure
Maintainability
As your app expands, managing navigation with React Navigation can become more complicated
With Expo Router, your app’s navigation structure is visually represented by the file system, simplifying understanding and maintenance
Deep Linking
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Universal Platform Support
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Universal Platform Support
Expo Router functions smoothly on Android, iOS, and the web, maintaining the same navigation structure across all platforms
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Universal Platform Support
Expo Router functions smoothly on Android, iOS, and the web, maintaining the same navigation structure across all platforms
This is especially useful when developing a cross-platform application
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Universal Platform Support
Expo Router functions smoothly on Android, iOS, and the web, maintaining the same navigation structure across all platforms
This is especially useful when developing a cross-platform application
Type Safety
Deep Linking
Expo Router automatically sets up deep linking for every screen in your app
This allows any route to be accessed directly through a URL, which is crucial for features like push notifications, link sharing, and web integration
Universal Platform Support
Expo Router functions smoothly on Android, iOS, and the web, maintaining the same navigation structure across all platforms
This is especially useful when developing a cross-platform application
Type Safety
Expo Router automatically types your routes, ensuring you can only link to valid routes and avoiding errors from linking to non-existent ones
Optimization
In production, routes are automatically optimised with lazy evaluation, while deferred bundling is used in development
Optimization
In production, routes are automatically optimised with lazy evaluation, while deferred bundling is used in development
This results in faster app loading and more efficient resource usage
Optimization
In production, routes are automatically optimised with lazy evaluation, while deferred bundling is used in development
This results in faster app loading and more efficient resource usage
Discoverability
Optimization
In production, routes are automatically optimised with lazy evaluation, while deferred bundling is used in development
This results in faster app loading and more efficient resource usage
Discoverability
Expo Router allows static rendering during build time on the web and connects to native apps.
Optimization
In production, routes are automatically optimised with lazy evaluation, while deferred bundling is used in development
This results in faster app loading and more efficient resource usage
Discoverability
Expo Router allows static rendering during build time on the web and connects to native apps.
This allows your app's content to be indexed by search engines, making it discoverable - a feature that's typically only available to web apps
Expo Router uses a file-system based routing system, meaning the routes available in your app are determined by how you structure your files and folders
Expo Router uses a file-system based routing system, meaning the routes available in your app are determined by how you structure your files and folders
"Does every file in our app automatically become a route?"
Expo Router uses a file-system based routing system, meaning the routes available in your app are determined by how you structure your files and folders
"Does every file in our app automatically become a route?"
Expo Router follows a convention-based structure
By following these conventions, the file is automatically treated as a route in your application
Files in the app folder that represent a unique route are called pages
By following these conventions, the file is automatically treated as a route in your application
http://localhost:8081/products
Product 1
Product 4
Product 2
Product 3
Product 5
Product 8
Product 6
Product 7
http://localhost:8081/products/1
Product 1
Product 1
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Rs: 440
Add to Cart
Buy Now
Dynamic routes enable the creation of parameterized paths, allowing a single route definition to handle various types of content
Dynamic routes enable the creation of parameterized paths, allowing a single route definition to handle various types of content
Dynamic route segments can be created by using square brackets in the names of files or folders
Dynamic routes enable the creation of parameterized paths, allowing a single route definition to handle various types of content
Dynamic route segments can be created by using square brackets in the names of files or folders
For Example: [param].tsx or [param]/index.tsx
Dynamic routes enable the creation of parameterized paths, allowing a single route definition to handle various types of content
Dynamic route segments can be created by using square brackets in the names of files or folders
For Example: [param].tsx or [param]/index.tsx
The text inside the brackets acts as a parameter that can be accessed
Within our components
http://localhost:8081/products/best-sellers/iphone
Product Details
http://localhost:8081/products/deals/black-friday/iphone
Product Details
http://localhost:8081/products/59883993
Product Details
1. SEO - Search engines. Can the system understand the product's context?
1. SEO - Search engines. Can the system understand the product's context?
2. User experience – URLs represent the navigation path followed.
1. SEO - Search engines. Can the system understand the product's context?
2. User experience – URLs represent the navigation path followed.
3. Analytics – Monitor how users find products.
- From best sellers: /products/best-sellers/iphone
- From featured deals: /products/deals/black-friday/iphone
- From search results: /products/search/iphone
- From recommendations: /products/recommended/for-you/iphone
- Direct product link: /products/123
- From best sellers: /products/best-sellers/iphone
- From featured deals: /products/deals/black-friday/iphone
- From search results: /products/search/iphone
- From recommendations: /products/recommended/for-you/iphone
- Direct product link: /products/123
- From best sellers: /products/best-sellers/iphone
- From featured deals: /products/deals/black-friday/iphone
- From search results: /products/search/iphone
- From recommendations: /products/recommended/for-you/iphone
- Direct product link: /products/123
Arbitrary depth: Imagine a list of topics stored in a CMS or database, where the depth can vary over time. We can't predict the maximum depth of the navigation tree and create files for each level
Code Duplication: Whether you're one level deep or ten, the UI used to display the content remains the same. If we rely on multiple levels of dynamic routes, we'll end up with many files and folders containing repetitive code
Arbitrary depth: Imagine a list of topics stored in a CMS or database, where the depth can vary over time. We can't predict the maximum depth of the navigation tree and create files for each level
In Expo Router, catch-all segments are defined using the spread syntax inside square brackets: [...params].tsx
In Expo Router, catch-all segments are defined using the spread syntax inside square brackets: [...params].tsx
This special syntax tells Expo Router to match any number of path segments and store them as an array
Pages are UI components that are specific to individual routes
Pages are UI components that are specific to individual routes
Layouts are UI components that wrap around pages, letting you share common elements across different routes
Pages are UI components that are specific to individual routes
Layouts are UI components that wrap around pages, letting you share common elements across different routes
Think of headers, footers, nav bars, or any UI elements that should stay consistent as users move through your app
Pages are UI components that are specific to individual routes
Layouts are UI components that wrap around pages, letting you share common elements across different routes
Think of headers, footers, nav bars, or any UI elements that should stay consistent as users move through your app
To create a layout, default export a React component from a _layout.js or _layout.tsx file
Pages are UI components that are specific to individual routes
Layouts are UI components that wrap around pages, letting you share common elements across different routes
Think of headers, footers, nav bars, or any UI elements that should stay consistent as users move through your app
To create a layout, default export a React component from a _layout.js or _layout.tsx file
The layout component renders the Slot component from Expo Router, which gets filled with your page content
Route Groups in Expo Router let you organize your routes logically without affecting the URL structure
Route Groups in Expo Router let you organize your routes logically without affecting the URL structure
You may want to organise related routes into a group
Route Groups in Expo Router let you organize your routes logically without affecting the URL structure
You may want to organise related routes into a group
You need to share layouts between specific routes
Route Groups in Expo Router let you organize your routes logically without affecting the URL structure
You may want to organise related routes into a group
You need to share layouts between specific routes
You may want to define multiple root layouts within your app
Imagine Stack Navigation as a deck of cards
Imagine Stack Navigation as a deck of cards
Every new screen you navigate to is like adding a new card on top of the stack
Imagine Stack Navigation as a deck of cards
Every new screen you navigate to is like adding a new card on top of the stack
When you go back, it's like removing the top card to reveal the one underneath
Imagine Stack Navigation as a deck of cards
Every new screen you navigate to is like adding a new card on top of the stack
When you go back, it's like removing the top card to reveal the one underneath
For example, when browsing a list of products, you tap one to view its details, then tap on a related product to see more information
Imagine Stack Navigation as a deck of cards
Every new screen you navigate to is like adding a new card on top of the stack
When you go back, it's like removing the top card to reveal the one underneath
For example, when browsing a list of products, you tap one to view its details, then tap on a related product to see more information
Expo Router simplifies the Stack Navigation implementation with its
built-in Stack component
Tab Navigation lets you move between different screens by tapping on a tab at the bottom of the screen
Tab Navigation lets you move between different screens by tapping on a tab at the bottom of the screen
If you open Reddit, Instagram, Spotify, or Twitter on your phone, you'll see a row of tabs at the bottom
If you’ve used apps like Gmail or Spotify, you’ve seen this before
If you’ve used apps like Gmail or Spotify, you’ve seen this before
When you tap the three-line (hamburger) icon or swipe from the edge, the menu comes in from the side
A modal is a screen that pops up over the app to show important info or ask you to choose something
A modal is a screen that pops up over the app to show important info or ask you to choose something
You can make modals in two different ways:
A modal is a screen that pops up over the app to show important info or ask you to choose something
You can make modals in two different ways:
- One way is to use the ‘Modal’ component in React Native
A modal is a screen that pops up over the app to show important info or ask you to choose something
You can make modals in two different ways:
- One way is to use the ‘Modal’ component in React Native
- Another way is to use Expo Router’s file-based setup.
Expo Router uses files to handle navigation in React Native apps
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Each platform has its own little differences:
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Each platform has its own little differences:
- iOS loves its sleek navigation stacks
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Each platform has its own little differences:
- iOS loves its sleek navigation stacks
- Android has a material design style
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Each platform has its own little differences:
- iOS loves its sleek navigation stacks
- Android has a material design style
- The web focuses on custom layouts and URLs
Expo Router uses files to handle navigation in React Native apps
Your app works on Android, iOS, and the web with just one codebase
Each platform has its own little differences:
- iOS loves its sleek navigation stacks
- Android has a material design style
- The web focuses on custom layouts and URLs
Platform-specific code lets you adjust your app’s behaviour or design for each platform, while keeping the same code structure
Page routes display UI components
Page routes display UI components
API Routes let you create RESTful endpoints and fully control the response
Page routes display UI components
API Routes let you create RESTful endpoints and fully control the response
It’s similar to creating a Node + Express app
Page routes display UI components
API Routes let you create RESTful endpoints and fully control the response
It’s similar to creating a Node + Express app
You don’t have to set up a separate server
Page routes display UI components
API Routes let you create RESTful endpoints and fully control the response
It’s similar to creating a Node + Express app
You don’t have to set up a separate server
API Routes are also useful for making external API requests
Page routes display UI components
API Routes let you create RESTful endpoints and fully control the response
It’s similar to creating a Node + Express app
You don’t have to set up a separate server
API Routes are also useful for making external API requests
Since they run on the server, sensitive info like private keys stays safe and doesn’t reach the browser