React BasicsCore· 35 min read

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

Terminal: scaffold and run a React app
# 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 dev

You run these three commands in your terminal, in order. Here is what each one does:

  1. Create the projectnpm create vite@latest my-app -- --template react asks Vite to build a fresh React project in a new folder called my-app. The --template react part says “set it up for React”.
  2. Go in and installcd my-app moves you into that new folder, and npm install downloads all the libraries the project needs (React itself and Vite). This creates the node_modules folder.
  3. Start the dev servernpm run dev launches Vite’s development server. Your terminal prints a local address (usually http://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 / folderWhat it is
index.htmlThe single HTML page (has the <div id="root">)
src/main.jsxEntry point — mounts React into the root
src/App.jsxYour main component — start editing here
src/components/Where you put your own components
package.jsonProject 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?

Answer: npm run dev runs the dev script defined in package.json, starting Vite’s dev server with hot reload.

✍️ Practice

  1. Create a Vite React app, install dependencies, and run the dev server.
  2. Edit src/App.jsx to show your name and watch it hot-reload.

🏠 Homework

  1. Explore the generated files and write a one-line note on what each key file does.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →