After react-native
started making waves the community built up a platform around the library to further abstract away
the mobile os specific aspects, like deployment.
Expo wraps 90% of the painful aspects of react-native
coming with about 30 native modules built in and offering easy
access to them from your app. The idea is you can set up the expo-cli
and bootstrap an app in minutes and hook it up
to your device. This is far easier than the early days of react-native
where you were forced to gain a good
understanding of at least the build process in order to deploy to your devices.
The way you can get started is by installing the expo-cli
npm init -y # create an npm workspace
npm i -g expo-cli
npx expo init coffeenut
We also need to install the expo-cli
in the created project folder as the cli interface will manage the local
simulators and we need to have expo
in scope.
If you plan to run on a simulator you need to have simulators configured for the desired platform by either XCode and the osx commandline tools or
Android Studio and the ANDROID_HOME
environment configured for the android tools.
If you havenβt done this prior to the workshop letβs take a break and work through this: Android and/or iOS
Now that we are all set up to run the app letβs go ahead and start up the app. Your package.json
should look something
like this providing quick npm scripts for the most useful actions
{
...
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
...
}
Letβs run the app
npm run ios # for iOS
npm run android # for android
We should be able to see our app running in the simulator of choice.