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
.
You will then use your arrow keys to select the React
option.
You will then need to select the JavaScript
variant.
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:
You can view some useful Shortcuts if you press h
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.
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).