Development Environment Setup
There are two main ways to develop React Native apps: Expo (managed workflow) and React Native CLI (bare workflow). Each has its advantages.
Expo vs React Native CLI
| Feature | Expo (Recommended) | React Native CLI |
|---|---|---|
| Setup Time | ~5 minutes | ~30+ minutes |
| Requirements | Node.js only | Xcode, Android Studio |
| Native Modules | Via Expo modules / EAS Build | Full access |
| OTA Updates | Built-in | Requires setup |
| Build Service | EAS Build (cloud) | Local builds |
| Best For | Most apps, rapid dev | Complex native needs |
π‘ Recommendation: Start with Expo
Expo is the recommended way to start React Native development. With Expo SDK 50+, you can use most native modules and "eject" to bare workflow later if needed.
Setting Up with Expo
# Create a new Expo project
npx create-expo-app@latest MyApp
cd MyApp
# Start the development server
npx expo start
# Project options:
npx create-expo-app@latest MyApp --template blank # Minimal setup
npx create-expo-app@latest MyApp --template tabs # Tab navigation
npx create-expo-app@latest MyApp --template blank-typescript # TypeScript
Expo Project Structure
my-expo-app/
βββ app/ # File-based routing (Expo Router)
β βββ (tabs)/ # Tab group layout
β β βββ _layout.tsx # Tab navigator config
β β βββ index.tsx # Home tab (/)
β β βββ explore.tsx # Explore tab (/explore)
β βββ _layout.tsx # Root layout
β βββ +not-found.tsx # 404 page
βββ assets/ # Images, fonts, etc.
β βββ images/
β βββ fonts/
βββ components/ # Reusable components
β βββ ThemedText.tsx
β βββ ThemedView.tsx
βββ constants/ # Theme, colors, etc.
β βββ Colors.ts
βββ hooks/ # Custom hooks
β βββ useColorScheme.ts
βββ app.json # Expo configuration
βββ babel.config.js # Babel configuration
βββ package.json
βββ tsconfig.json # TypeScript config
app.json Configuration
// app.json - Expo configuration
{
"expo": {
"name": "MyApp",
"slug": "my-app",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.yourcompany.myapp"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.yourcompany.myapp"
},
"web": {
"bundler": "metro",
"output": "static"
},
"plugins": [
"expo-router",
["expo-camera", { "cameraPermission": "Allow camera access" }]
]
}
}
Setting Up React Native CLI
# Prerequisites for React Native CLI
# macOS (for iOS development)
# 1. Install Xcode from App Store
# 2. Install Xcode Command Line Tools
xcode-select --install
# 3. Install CocoaPods
sudo gem install cocoapods
# 4. Install Watchman (optional but recommended)
brew install watchman
# Android (for Android development)
# 1. Install Android Studio
# 2. Install Android SDK (via Android Studio)
# 3. Set environment variables in ~/.zshrc or ~/.bashrc:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Create a new React Native CLI project
npx react-native@latest init MyApp
cd MyApp
# Run on iOS
npx react-native run-ios
# Run on Android
npx react-native run-android
React Native CLI Project Structure
my-rn-app/
βββ android/ # Android native code
β βββ app/
β β βββ build.gradle
β β βββ src/main/
β βββ build.gradle
β βββ settings.gradle
βββ ios/ # iOS native code
β βββ MyApp/
β β βββ AppDelegate.mm
β β βββ Info.plist
β βββ MyApp.xcodeproj
β βββ Podfile
βββ src/ # Your source code (create this)
β βββ components/
β βββ screens/
β βββ navigation/
β βββ hooks/
β βββ utils/
β βββ services/
βββ App.tsx # Entry component
βββ index.js # Entry point
βββ metro.config.js # Metro bundler config
βββ babel.config.js
βββ package.json
βββ tsconfig.json
Recommended Folder Structure
src/
βββ components/ # Reusable UI components
β βββ Button/
β β βββ Button.tsx
β β βββ Button.styles.ts
β β βββ index.ts
β βββ Card/
βββ screens/ # Screen components
β βββ HomeScreen/
β β βββ HomeScreen.tsx
β β βββ HomeScreen.styles.ts
β β βββ components/ # Screen-specific components
β βββ ProfileScreen/
βββ navigation/ # React Navigation setup
β βββ RootNavigator.tsx
β βββ TabNavigator.tsx
β βββ types.ts
βββ hooks/ # Custom hooks
β βββ useAuth.ts
β βββ useApi.ts
βββ services/ # API, storage, etc.
β βββ api/
β β βββ client.ts
β β βββ endpoints.ts
β βββ storage/
βββ store/ # State management
β βββ slices/
β βββ store.ts
βββ utils/ # Helper functions
β βββ formatting.ts
β βββ validation.ts
βββ constants/ # App constants
β βββ colors.ts
β βββ typography.ts
β βββ spacing.ts
βββ types/ # TypeScript types
β βββ index.ts
βββ assets/ # Images, fonts, etc.
Development Tools
# Essential development tools
# Expo Go App (for Expo projects)
# Download from App Store / Play Store
# Scan QR code to preview your app
# React Native Debugger (for RN CLI)
brew install --cask react-native-debugger
# Flipper (Meta's debugging platform)
brew install --cask flipper
# VS Code Extensions
# - React Native Tools
# - ES7+ React/Redux/React-Native snippets
# - Prettier
# - ESLint
# Useful commands
npx expo start --clear # Clear cache and start
npx expo start --ios # Start and open iOS simulator
npx expo start --android # Start and open Android emulator
# React Native CLI
npx react-native start --reset-cache
npx react-native doctor # Check environment setup
β‘ Quick Start Commands
# Fastest way to start (Expo)
npx create-expo-app@latest MyApp
cd MyApp
npx expo start
# Then:
# - Press 'i' for iOS Simulator
# - Press 'a' for Android Emulator
# - Scan QR code with Expo Go app on device