Welcome to the React Native setup guide! This tutorial will walk you through the essential steps to get your development environment ready to build native mobile applications with React Native.
Before you begin, ensure you have the following installed:
brew install watchman
React Native offers two main ways to get started:
This is the quickest way to get started.
Install the Expo CLI globally:
npm install -g expo-cli
Create a new project:
expo init my-react-native-app
Follow the prompts to choose a template (e.g., a blank template).
Navigate into your project directory:
cd my-react-native-app
Start the development server:
expo start
This will open a QR code in your terminal and a browser tab with the Expo Dev Tools.
This method requires more setup but provides greater flexibility.
Install the React Native CLI globally:
npm install -g react-native-cli
Create a new project:
react-native init MyReactNativeApp
Navigate into your project directory:
cd MyReactNativeApp
For iOS:
Install dependencies and run on the simulator:
npm install
npx pod-install ios
npx react-native run-ios
For physical devices, you'll need Xcode installed and configured.
For Android:
Install dependencies and run on an emulator or physical device:
npm install
npx react-native run-android
This requires Android Studio and the Android SDK to be set up correctly. Refer to the official React Native documentation for detailed Android environment setup.
Common issues and solutions:
expo start -c
(for Expo)
react-native start --reset-cache
(for React Native CLI)
rm -rf node_modules
npm install
Congratulations! You've successfully set up your React Native development environment. Now you're ready to start building amazing mobile applications.