Technology Encyclopedia Home >How to create a new project in React Native?

How to create a new project in React Native?

Creating a new project in React Native involves using the command-line interface (CLI) tool. Here’s how you can do it:

  1. Install React Native CLI: If you haven't already, you need to install the React Native CLI globally using npm (Node Package Manager). Open your terminal or command prompt and run:

    npm install -g react-native-cli
    
  2. Create a New Project: Once installed, you can create a new React Native project by running:

    npx react-native init ProjectName
    

    Replace ProjectName with the name you want for your project. This command will set up a basic project structure for you.

  3. Navigate to the Project Directory: After the project is created, navigate into the project directory using:

    cd ProjectName
    
  4. Run the Project: To start the development server and run the app in an emulator or on your physical device, use:

    npx react-native run-android
    

    or

    npx react-native run-ios
    

    Depending on whether you want to run the app on an Android or iOS device/emulator.

Example:
If you want to create a project named "MyFirstApp", you would run:

npx react-native init MyFirstApp
cd MyFirstApp
npx react-native run-android

For cloud-related functionalities in your React Native app, consider using services like Tencent Cloud's Cloud Functions for serverless computing, or Cloud Storage for storing and retrieving data. These services can help you manage backend operations without the need to maintain your own servers.