Your First React App
🌟 Your First React App
In this lesson, you’ll:
-
Create a new React project
-
Run the development server
-
Edit your first component
We’ll use Vite because it’s fast and modern — recommended for React beginners.
🛠 Step 1: Create a React Project
Open your command prompt/terminal and run:
Enter the folder:
Install dependencies:
Run the app:
You will see a URL like:
👉 http://localhost:5173
Open it in your browser — Congratulations, React is running! 🎉
📁 Project Structure Overview
Inside the folder, you will see:
Key files:
| File | Purpose |
|---|---|
main.jsx |
Entry file that renders React app |
App.jsx |
Main component that displays UI |
index.html |
Actual HTML served to browser |
🧩 Step 2: Understanding main.jsx
Open src/main.jsx:
🧠 This code tells React:
“Render
<App />inside the HTML element with idroot.”
✏ Step 3: Edit Your First Component (App.jsx)
Open src/App.jsx and replace content with:
💡 The browser updates automatically — no refresh needed!
⚙ How It Works
React uses components (like Lego blocks) to build UI.App() is your first component.
It returns JSX — a syntax that looks like HTML but runs inside JavaScript.
🎉 You Just Built Your First React App!
You now know how to:
✔ Create a React project
✔ Run the app
✔ Edit a component
✔ Use JSX
