Vite (French word for “quick”, pronounced /vit/
, like “veet”) is a build tool that aims to provide a faster and leaner development experience for modern web projects. It consists of two major parts:
- A dev server that provides rich feature enhancements over native ES modules, for example extremely fast Hot Module Replacement (HMR).
- A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production.
You can try Vite online on StackBlitz. It runs the Vite-based build setup directly in the browser, so it is almost identical to the local setup but doesn’t require installing anything on your machine.
Here is a step-by-step guide:
Prerequisites
- Node.js
First, make sure you have Node.js installed on your computer. You can download and install it from the official Node.js website: https://nodejs.org/
1. Create a new React app using Vite
Open your terminal or command prompt and use the following command to create a new React app using Vite:
npm create vite@latest
During the installation process, you will be prompted with the following options:
Need to install the following packages:
create-vite@5.2.3
Ok to proceed? (y)
Press the Y and Enter key to continue.
Then set the project name and select a framework (React).
? Select a framework: › - Use arrow-keys. Return to submit.
❯ Vanilla
Vue
React
Preact
Lit
Svelte
Solid
Qwik
Others
Select a variant (TypeScript).
✔ Project name: … demo
✔ Select a framework: › React
? Select a variant: › - Use arrow-keys. Return to submit.
❯ TypeScript
TypeScript + SWC
JavaScript
JavaScript + SWC
Remix ↗
The new project/application has been created.
2. Install dependencies
Go to the project directory.
cd <app_name>
Replace
with the name of your project.<app_name>
Use the following command to install dependencies.
npm install
The node_modules folder with dependencies has been created.
3. Start the development server
Start the development server by running:
npm run dev
This command will start the development server.
VITE v5.2.10 ready in 126 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Open your web browser and enter http://localhost:5173/ into the address bar.