How to Create React App With Vite

Advertisement

You can use Vite to create a React project.

Vite is a build tool that is gaining some popularity in the web development space.

With Vite, you can create frontend project in React, Vue, Preact, Svelte, Lit, and Vanilla Javascript.

Vite is promising a better development experience for developers.

Creating React App Using Vite

To create your first React app with Vite, you need:

  • Node.js
  • npm version 6 and above

1. NPM method

Check your npm version by running npm -v or npm --version in the terminal.

If you have npm version 6, you can create your React app by running:

npm create vite@latest my-vue-app --template react

For npm version 7 and above, run:

npm create vite@latest my-vue-app -- --template react

Note the extra extra double-dash. It is required.

2. Yarn Method

You can also setup a Vite React project using Yarn. In your commandline tool, run:

yarn create vite my-vue-app --template react

my-vue-app is the name of your react app. You can change my-vue-app to any name you want.

You can also create a React app:

  1. using NPM
  2. using Yarn
  3. using Vite
  4. without using Node
author's bio photo

Hi there! I am Avic Ndugu.

I have published 100+ blog posts on HTML, CSS, Javascript, React and other related topics. When I am not writing, I enjoy reading, hiking and listening to podcasts.