Generate a React App in The Command Line – Quick Start.

There are different ways to create a react app. Before creating react app, you need to be sure that nodejs is installed on your machine.

1. Check the node version installed on your machine.

Open a terminal and run the following code:

C:\Users\Admin> node -v

If nodejs is installed on your machine, you will see something like the one shown below.

Notice that here I have node version 18.19.0 installed on my machine.

2. Create React App.

We can create a react app in two ways:

  1. By using a called create-react-app ( CRP ).
  2. By using a tool called Vite.

Option 1: Using the CRP

2. 1. Using the first option: navigate inside the folder that you would like to store your project and run the following command.

C:\Users\Admin\react-project> npx create-react-app my-app-name

This will generate a brand new react app for you with the name you have specified.

Next, navigate into the project folder and run the following command.

C:\Users\Admin\react-project\my-app-folder> npm install    
C:\Users\Admin\react-project\my-app-folder> npm run dev

Then you can check your app out in the browser

Option 2: Using Vite.

2. 2. Using the second option: navigate inside the folder that you would like to store your project and run the following command.

C:\Users\Admin\react-project> npm create vite@latest  

OR you can specify a specific version by saying :

C:\Users\Admin\react-project> npm create vite@4.1.0

Assuming that is the version you would like to use. Then follow all the steps and answer the questions according to your need to complete creating your app. Then you can just follow the steps stated in listing 2.1 to view your application on the browser.

Happy coding…