How do you create a new React Native project?

You can create a new React Native project using Expo CLI (easier setup) or React Native CLI (more control). Here’s how:

1. Using Expo CLI (Recommended for Beginners)

Expo is a framework that simplifies React Native development by handling configurations.

Step 1: Install Node.js and npm

Make sure you have Node.js installed. You can check by running:

node -v
npm -v

If not installed, download it from nodejs.org.

Step 2: Install Expo CLI

Run the following command to install Expo CLI globally:

npm install -g expo-cli
Step 3: Create a New Expo Project

Run:

npx create-expo-app MyNewApp

Replace MyNewApp with your project name.

Step 4: Navigate to Your Project
cd MyNewApp
Step 5: Start the Development Server
npm start

or

expo start

This will open the Expo Developer Tools in your browser. You can scan the QR code using the Expo Go app on your phone to run the app.


2. Using React Native CLI (For Advanced Users)

If you need more control (e.g., native modules, deeper customization), use React Native CLI.

Step 1: Install Node.js, npm, and Watchman
  • Install Node.js (from nodejs.org)
  • Install Watchman (macOS only):
    brew install watchman
    
Step 2: Install React Native CLI

You don't need to install it globally. Just use:

npx react-native init MyNewApp
Step 3: Navigate to Your Project
cd MyNewApp
Step 4: Run the App

For Android:

npx react-native run-android

For iOS (Mac + Xcode required):

npx react-native run-ios

Note: You need to have Android Studio (for Android) or Xcode (for iOS) set up properly.


Which One Should You Use?
  • Expo CLI → Best for quick development, no native code modifications.
  • React Native CLI → Best for full control over the native code.