Files
github-actions[bot]andamandeepmittal 0073f46826 Upgraded Expo SDK to expo@latest (#701)
This PR was automatically created by the [upgrade
workflow](./.github/workflows/upgrade.yml).

> ⚠️ Review the [job
logs](https://github.com/expo/examples/actions/runs/28587793003) before
merging

Co-authored-by: amandeepmittal <[email protected]>
2026-07-02 18:05:43 +05:30
..
2020-01-16 14:59:02 -08:00
2021-12-21 19:02:50 -07:00
2020-12-11 18:35:54 +01:00

React Router Example

Supports Expo iOS Supports Expo Android Supports Expo Web

React Router is a universal routing solution that you can use with Expo! This demo shows you how to setup your universal application to switch between web and native routers.

Launch your own

Launch with Expo

⚽️ Running in the browser

  • Create Expo project expo init
  • Install the plugin: yarn add react-router-dom react-router-native or npm install --save react-router-dom react-router-native
  • Create platform specific files to switch between web and native:
  • Now you can use these files to create your universal routes! Basic Example

react-router-native-expo-web-example react-router-dom-expo-web-example

Deploying to Netlify

You may find get the following error when visiting URLs other than '/' on when your single page application (SPA) is deployed to Netlify:

netlify-error

Page Not Found Looks like you've followed a broken link or entered a URL that doesn't exist on this site.

The problem is that react-router creates the routes on the client side so when you visit pages other than the root (ex: coolproject.netlify.com/about), Netlify won't know how to redirect the route.

Luckily the solution for this is simple! We can use the redirects API provided by Netlify.

  • Create a web/_redirects to redirect all routes to the index.html:
    /*    /index.html   200
    
    • Creating files in the web/ folder will copy them to the build folder (web-build/). Think of this like public/ in Create React App projects.
  • Now simply rebuild (expo build:web) and deploy your web app (netlify deploy --dir web-build)!

Example