Setting Up a React Project (Vite)
Create a real React project on your computer with Vite — the fast, modern toolchain.
What you will learn
- Create a React app with Vite
- Understand the project structure
- Run the dev server
Why a build tool?
Real React projects are not loaded from a CDN — they use a build tool that bundles your files, understands JSX, and gives you instant hot reload. The modern favourite is Vite (fast and simple).
Watch out: You need Node.js installed first (it includes npm). Check with node -v in your terminal. If it is missing, install it from nodejs.org — you will also need it for the Node/Express part of MERN.
Create and run
# create a new React project
npm create vite@latest my-app -- --template react
# go into it and install dependencies
cd my-app
npm install
# start the dev server (hot reload!)
npm run devYou run these three commands in your terminal, in order. Here is what each one does:
- Create the project —
npm create vite@latest my-app -- --template reactasks Vite to build a fresh React project in a new folder calledmy-app. The--template reactpart says “set it up for React”. - Go in and install —
cd my-appmoves you into that new folder, andnpm installdownloads all the libraries the project needs (React itself and Vite). This creates thenode_modulesfolder. - Start the dev server —
npm run devlaunches Vite’s development server. Your terminal prints a local address (usuallyhttp://localhost:5173). Open it in your browser to see your app, and it updates instantly every time you save a file.
Note: Output (after npm run dev):
VITE ready in 320 ms
➜ Local: http://localhost:5173/
Open that address in your browser and you will see the starter React page. Leave this command running while you work — stop it later with Ctrl + C.
The key files
| File / folder | What it is |
|---|---|
index.html | The single HTML page (has the <div id="root">) |
src/main.jsx | Entry point — mounts React into the root |
src/App.jsx | Your main component — start editing here |
src/components/ | Where you put your own components |
package.json | Project info and dependencies |
How they fit together: the browser loads index.html, which has an empty <div id="root">. src/main.jsx runs and mounts your React app into that div. The first thing it shows is src/App.jsx — so App.jsx is where you start editing. As your app grows, you add new components inside src/components/ and bring them into App.jsx.
Tip: Open src/App.jsx, change some text, and save — the browser updates instantly without a reload. That is hot reload, and it makes development a joy.
Q. Which command starts the Vite development server?
✍️ Practice
- Create a Vite React app, install dependencies, and run the dev server.
- Edit
src/App.jsxto show your name and watch it hot-reload.
🏠 Homework
- Explore the generated files and write a one-line note on what each key file does.