To install React, you can use Create React App, a popular command-line tool provided by Facebook to quickly set up a new React project with all the necessary dependencies and configurations. Here's how you can install React using Create React App:
Step 1: Install Node.js Before installing React, make sure you have Node.js installed on your computer. Visit the official Node.js website (https://nodejs.org) and download the latest LTS version for your operating system. Follow the installation instructions to set up Node.js.
Step 2: Install Create React App Once Node.js is installed, open your terminal or command prompt and run the following command to install Create React App globally on your system:
Step 3: Create a New React Project After installing Create React App, you can use it to create a new React project. In your terminal or command prompt, navigate to the directory where you want to create your project and run the following command:
Replace "my-app" with your preferred project name. The above command will create a new directory with the specified name and set up a basic React project inside it.
Step 4: Navigate to the Project Directory Change your working directory to the newly created project directory:
cd my-app
Step 5: Start the Development Server In the project directory, run the following command to start the development server:
npm start
This command will compile your React code and open the app in your default web browser. Any changes you make to your code will automatically refresh the page.