For many years, create-react-app (CRA) was the standard boilerplate tool for bootstrapping React projects. CRA relied internally on Webpack, which bundled every JavaScript file, CSS file, and third-party dependency into a single massive memory bundle before starting the local development server. As applications expanded, cold-start build times stretched into minutes, and Hot Module Replacement (HMR) experienced noticeable lag.
Vite (pronounced veet, French for "quick") fundamentally redefined front-end build tooling by capitalizing on modern browser capabilities and native ES Modules (ESM):
Instant Cold Server Start: Vite does not bundle source code upfront during development. Instead, it serves source code over native ESM, allowing the browser to load individual modules on demand as requested.
Lightning-Fast HMR: Utilizing esbuild (written in Go), Vite pre-bundles external dependencies 10 to 100 times faster than JavaScript-based bundlers. Changes to components update almost instantaneously in the browser without losing component state.
Optimized Production Bundles: When deploying to production, Vite employs Rollup under the hood to output highly optimized, tree-shaken, and chunk-split static assets.
7# Install project dependencies listed in package.json
8npminstall
9
10# Launch the local development server
11npm run dev
The terminal will output the local network URL (typically http://localhost:5173). Opening this link in any modern browser displays your active Vite + React environment with live Hot Module Replacement enabled.
4. Understanding the Core Configuration Files
package.json
Specifies your application scripts, development tools, and production dependencies:
1{
2"name":"msk-react-starter",
3"private":true,
4"version":"1.0.0",
5"type":"module",
6"scripts":{
7"dev":"vite",
8"build":"vite build",
9"preview":"vite preview"
10},
11"dependencies":{
12"react":"^18.3.1",
13"react-dom":"^18.3.1"
14},
15"devDependencies":{
16"@vitejs/plugin-react":"^4.3.0",
17"vite":"^5.3.0"
18}
19}
vite.config.js
The central build configuration file where official plugins such as @vitejs/plugin-react are registered:
1import{ defineConfig }from'vite';
2import react from'@vitejs/plugin-react';
3
4// https://vitejs.dev/config/
5exportdefaultdefineConfig({
6plugins:[react()],
7server:{
8port:3000,
9open:true
10}
11});
Interactive Quiz• Knowledge Check
Practice Quiz
Question 1
What major development feature allows Vite to start local development servers almost instantaneously?
Question 2
Which underlying tool does Vite use for high-speed dependency pre-bundling during development?
Question 3
What terminal command is used to launch the Vite local development server?
Question 4
By default, what port does the Vite development server bind to?
Question 5
Which file contains the list of installed packages, scripts, and project metadata in a React application?
Next Lesson
React Project Directory Structure and Entry Points
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.