React Native allow React developers to create native apps for Android and iOS devices.
The React Native team strongly recommend using a framework when you are developing apps with React Native, Expo is one of the frameworks that provide various features and necessary APIs make the development much easier.
Start a new React Native project
To start with, run the following in your terminal:
1 | npx create-expo-app@latest |
Set up an Android device with a development build
In this section, I am going to build my app with Expo Application Services (EAS). We don’t need to install Android studio to build and compile the app on our local machine, EAS does this work for us in the cloud and produce a build that we can install on our devices.
Install EAS CLI:
1 | npm install -g eas-cli |
Create an Expo account and login
Sign up for an Expo account if you don’t have one, then run the following command to login:
1 | eas login |
Next, run this command in the root of your project to create an EAS config:
1 | eas build:configure |
Run the following command to create a development build:
1 | eas build --platform android --profile development |
When the build is complete, scan the QR code in your terminal or open the link on your mobile devices. Tap Install to download the build and then Open to install it.
Start Expo server
The Expo server is only accessible for localhost, if you need to make it reachable for other devices in the same network, you need to change the start
script in package.json
by adding the --host
parameter:
1 | "scripts": { |
Run npm start
and you will see something on the terminal like:
1 | › Metro waiting on exp+ai-reports-app://expo-development-client/?url=http%3A%2F%2F172.20.10.5%3A8081 |
Then your server URL is http://172.20.10.5:8081
.
Turn off your Firewall on your dev machine
This is NOT the best practice, however this is the easiest way to make your Expo server accessible for other devices.
Open the server url in a web browser on your mobile device make sure it is running properly.
Input the server URL in your Expo app
Tap to start the Expo app on your device, then input the server URL mannually to connect to the dev server.