TechLead
Lesson 2 of 8

Environment Setup & Project Structure

Setting up development environment, Expo vs CLI, and project organization

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