React is one of the most popular JavaScript libraries for building user interfaces. If you’re just getting started with React, the easiest way to create a new project is by using Create React App (CRA). This tool sets up everything you need, so you can focus on writing your application instead of configuring your development environment.
Step 1: Install Node.js
Before creating a React app, you need to have Node.js installed on your system. Node.js comes with npm (Node Package Manager), which is required to install React and other dependencies.
To check if Node.js is installed, open your terminal or command prompt and run:
node -v npm -v
If you don’t have Node.js installed, download and install it from the official website.
Step 2: Create a New React App
Once Node.js is installed, you can create a new React application using the following command:
npx create-react-app my-app
npx
runs the package without installing it globally.create-react-app
is the CLI tool that sets up your React project.my-app
is the name of your project (you can replace it with your preferred name).
This command will take a few minutes to install all the necessary dependencies.
Step 3: Navigate to Your Project Directory
After the installation is complete, navigate into your project folder:
cd my-app
Step 4: Start the Development Server
To start the React application, run the following command:
npm start OR yarn start
This will launch your React app in the default web browser at http://localhost:3000/.
Conclusion
You have successfully created a React application using Create React App (CRA). Now, you can start building your React project by adding components, state management, and more!
Useful Links
Download Nodejs- https://nodejs.org/en/download/
Download VS code- https://code.visualstudio.com/docs/?dv=win64user
Download Yarn – https://classic.yarnpkg.com/en/docs/install#windows-stable
Create React App- https://create-react-app.dev/docs/getting-started