6. What is Vite
β‘ Setting Up a React Project with Vite
What is Vite?
-
Vite (means βfastβ in French) is a modern build tool for quickly creating web projects.
-
Works with React, Vue, Svelte, or even vanilla JavaScript.
-
Provides a faster development experience with minimal setup.
π§± Why Use Vite?
β
Automatically sets up all required configurations.
β
Generates only the files you actually need.
β
Much faster than older tools like Create React App.
π₯οΈ Creating a New React Project
Step 1: Open your command line (Command Prompt, PowerShell, or Terminal).
Step 2: Run this command:
npm create vite@latest my-react-app -- --template react
Creates a new React project called my-react-app using Viteβs React template.
βοΈ Installing Dependencies
After the project is created, run:
cd my-react-app
npm install
-
cd my-react-appβ moves into your project folder. -
npm installβ installs all dependencies listed in yourpackage.jsonfile.
π¦ Dependencies = external libraries your app needs (like React, ReactDOM, etc.).
π Important Files & Folders
-
package.jsonβ stores project info, dependencies, and scripts. -
node_modulesβ contains the actual code for all installed packages.
π Running the Project
Start your local server:
npm run dev
π§© Editing Your App
-
Go to
src/App.jsxβ this is your main component file. -
Edit and save it β changes appear instantly in your browser (hot reload).
In short:
Vite makes starting a React project super fast and simple.
It handles setup, dependencies, and dev server automatically β so you can focus on building your app, not configuring tools.