There are many ways and tools to develop mobile apps, such as ionic, react-native, flutter, swift, kotlin, and many more. Today, we will use react native for mobile app development.
When you first develop a mobile app with React Native, make sure to install some of the following:
- node
- android studio
- xcode ( for macOS only )
Setup with NodeJs
If you have never installed NodeJs, we can install it from the official Node Js website: https://nodejs.org/en/download/package-manager.
We can install with package-manager (nvm) or bundler applications like .dmg for macOS and .exe for windows. After the installation is complete, next we will run the command
npx react-native@latest init MyApp
If you run the command above and we get an error, we can skip the setup and install the pods, by following the following command:
npx react-native@latest init MyApp --version 0.74.5 --pm npm --install-pods false
Setup with Android Studio
If you have never installed Android Studio on your computer, we must download the Android Studio on Official website. https://developer.android.com/studio
After installation is completed, we will next to download the SDK needed.
We need to setup a bash profile or zsh profile for Android Path.
# android
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
alias adb="$ANDROID_HOME/platform-tools/adb"
And then don't forget to install openjdk for Runtime Java. For macOS user we can install with homebrew
. Command like this:
brew install openjdk
We have to configure the bash profile for OpenJDK
# openjdk
export PATH="/usr/local/opt/openjdk/bin:$PATH" # for latest version
export PATH="/usr/local/opt/openjdk@17/bin:$PATH" # for version 17
Now we can check the react-native prerequisite with command
npx react-native doctor
If no errors occur, the result will be like this:
Conclusion
With React Native we can create mobile applications on various platforms both Android and iOS, maybe the next application can run on the web or desktop soon. If you were previously a web developer switching to a React Native developer is not difficult.