Create a React Application

Now that we understand more about React and components, we are ready to build a React app. To make a new React application, we will be using a front-end tool called Vite . This will allow us to scaffold a new React project with the required dependencies and launch a local dev server.

To get started we first need to install vite within the project directory.

npm create vite@latest

You will be asked to provide a name for the project. The below example uses the name react-part-one.

Image of creating a new react app with vite

You will then use your arrow keys to select the React option.

Image of selecting a variant after running npm create vite@latest command

You will then need to select the JavaScript variant.

Image of complete scaffolded React project using Vite

Now that your project has scaffolded you can navigate into the project root directory and run the following commands:

npm install
npm run dev

This will start your local development server and you will see output similar to the below image:

Image of running application on localhost:5173 after executing the npm run dev command

You can view some useful Shortcuts if you press h

Image of Shortcuts after pressing h which is available after executing the npm run dev command

At this point you can either open a web browser and navigate to http://localhost:5173 or press o if you are within the terminal window running the application.

Image of running react application scaffolded with Vite

Note

You do not need to press h in order for the shortcuts to work. Once the app is running you can press o to view the application within the browser (if you are currently within the terminal window running the application).