Coder Social home page Coder Social logo

react-native-first's Introduction

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.

⚽️ 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

react-native-first's People

Contributors

emorilebo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.