Projects

Creating a New React Project Using Create React App

Now that you have Node.js , npm , and VS Code installed and set up, it’s time to create your very first React project! This will be your workspace where you’ll write, test, and run your React code. We’ll be using a tool called **Create React App** to make this process easy and fast.

What is Create React App?

Create React App is a tool developed by the React team to help you quickly set up a React project with all the necessary files and configurations. Think of it as a "starter kit" for React. You won’t have to manually set up a bunch of files or worry about configuration—Create React App does all that for you.

It’s like getting a ready-to-cook meal kit. Instead of buying each ingredient separately and figuring out how to prepare them, you get everything neatly packed and ready to use.

Why Use Create React App?

There are many benefits to using Create React App, especially for beginners:

Step-by-Step Guide: Creating a React Project

Let’s walk through the steps to create your first React project using Create React App .

Step 1: Open Your Terminal

The first thing you need to do is open a terminal (also called a command line). In VS Code, there’s a built-in terminal that you can use, so let’s do that:

Step 2: Navigate to Your Desired Folder

Next, you need to decide where on your computer you want to create your React project. This could be inside a folder where you keep all your coding projects, for example. Here’s how you can navigate to the folder you want to work in:

Step 3: Run the Create React App Command

Now comes the exciting part: creating your project! To do this, we’ll use npm (which you installed with Node.js). In the terminal, run the following command:

npx create-react-app my-first-react-app

Here’s what this command does:

Once you hit Enter , Create React App will start building your project. It might take a minute or two to install everything. During this time, it’s setting up all the necessary files and dependencies for you. You’ll see a lot of messages in the terminal, but don’t worry—this is completely normal!

Step 4: Open Your New React Project

After the installation is complete, you’ll have a new folder called `my-first-react-app` (or whatever you named your project) in the folder where you ran the command. This folder contains all the files for your React project.

Step 5: Start the Development Server

Before you start coding, let’s see if everything is working correctly by running your React project. React comes with a built-in development server that allows you to see your project in action while you’re building it. To start the server, type the following command:

npm start

This will start the development server, and your React app will automatically open in your web browser. By default, it opens on http://localhost:3000 . If everything is set up correctly, you should see the default React welcome page that looks like this:

React logo

Congratulations! You’ve successfully created your first React project and it’s running locally on your computer!

What’s Inside Your New React Project?

Now that your React app is up and running, let’s take a quick look at the project structure. Inside the `my-first-react-app` folder, you’ll see several files and folders that were automatically created for you:

What’s Next?

Now that you’ve set up your first React project, you’re ready to start building amazing things with React! In the next section, we’ll dive into JSX (JavaScript XML) and see how React allows you to build user interfaces using components.