Table of Contents
React Native is a popular framework for building mobile applications using JavaScript and React. Whether you're a beginner or an experienced developer, setting up a new React Native project can be quick and straightforward. In this tutorial, we'll walk through the steps to create a React Native app from scratch in just 30 minutes.
Prerequisites
- Node.js installed (version 14 or higher)
- Watchman (for macOS users)
- Java Development Kit (JDK) for Android development
- Android Studio or Xcode for iOS development
- Basic knowledge of JavaScript and React
Step 1: Install React Native CLI
Open your terminal and run the following command to install the React Native CLI globally:
npm install -g react-native-cli
Step 2: Create a New Project
Navigate to the directory where you want to create your project and run:
react-native init MyFirstApp
Step 3: Run Your App on Android
Ensure your Android emulator is running or a device is connected. Then execute:
cd MyFirstApp
npx react-native run-android
Step 4: Run Your App on iOS
On macOS with Xcode installed, run:
npx react-native run-ios
Step 5: Modify Your App
Open the project in your code editor. The main file is App.js. You can customize it to change your app's interface and functionality.
Additional Tips
- Use Metro Bundler for fast refresh and debugging.
- Install additional libraries via npm or yarn.
- Consult the React Native documentation for advanced topics.
Congratulations! You've set up your first React Native project and are ready to start building your mobile app.