In this blog post I will explain what is Vite and how you can create new react js app using Vite
It consists of two major parts
- A dev server that provides extremely fast Hot Module Replacement (HMR)
- A build command that bundles your code with Rollup
Vite doesn’t bundle the code in advance. Instead, when the browser asks for a file, Vite transforms it.
- On demand file serving over native ESM
- Hot Module Replacement (HMR)
- Out-of-the-box support for TypeScript, JSX, CSS and more
- Optimized build with Rollup JS
- Plugin support
- Fully Typed APIs with full TypeScript
[icon name=”clipboard” prefix=”fas”] Note
Vite requires Node.js version >=12.0.0
you can install Vite using below commands
npm init vite@latestCode language: Makefile (makefile)
yarn create viteCode language: Shell Session (shell)
pnpm create viteCode language: Shell Session (shell)
Following the prompt you can create a project.
You can also directly specify the project name and the template you want to use via additional command line options
Vite currently supports below framework templates.
Creating React JS App using Vite
For creating React JS app with
Vite you can use below command line options.
# npm 6.x npm create vite my-react-app --template react # If you want to create react project with typescript npm create vite my-react-app --template react-ts # npm 7+, extra double-dash is needed: npm create vite my-react-app -- --template react # yarn yarn create vite my-react-app --template react # pnpm pnpm create vite my-react-app -- --template reactCode language: Java (java)
Now change to project directory and run below command to install the npm packages
npm installCode language: Shell Session (shell)
After installing dependencies, you can start the application with following command
Now open your browser, and point it to
The whole project scaffolding process takes less than1 minute.
Trying Vite Online
You can try Vite online on StackBlitz. It runs the Vite-based build setup directly in the browser
You can find community curated plugins and templates for various frameworks in following Git repo