DEV Community

Posen992
Posen992

Posted on

How to use Vite to start a React Project

Here are the steps to use Vite to start a React Project:

1. Navigate to the directory where you want to create the project:

Use the cd command in Terminal to navigate to the directory where you want to create the project. For example:

cd path/to/your/directory
Enter fullscreen mode Exit fullscreen mode

2. Create a React project:

In the same directory, run the following command to create a new Vite project with the React template:

npm create vite@latest my-react-app -- --template react
Enter fullscreen mode Exit fullscreen mode

This will create a folder named my-react-app in the current directory and initialize the project inside it.

3. Enter the project directory:

Use the cd command to enter the newly created project directory:

cd my-react-app
Enter fullscreen mode Exit fullscreen mode

4. Install dependencies:

Run the following command in the project directory to install the project dependencies:

npm install
Enter fullscreen mode Exit fullscreen mode

If some errors will occur in this problem, please go to Errors occurred while using Vite

5. Start the development server:

Finally, run the following command to start the Vite development server:

sudo npm run dev
Enter fullscreen mode Exit fullscreen mode

The console shows that the application has started on localhost port 5173, i.e. the address http://localhost:5173/:

run dev s.png

By following these steps, you have successfully created and started a new React project in the directory of your choice.

Top comments (0)