Step 1: Install Bun
Bun installs packages and runs scripts. If you did the Node.js course you already have it.
# macOS or Linux$curl -fsSL https://bun.sh/install | bash# Windows (PowerShell)$powershell -c "irm bun.sh/install.ps1 | iex"$bun --version
Step 2: Create the To-Do app
$bun create vite todo-app --template react-ts$cd todo-app$bun install$bun run dev
react-ts means React with TypeScript. When it starts, Vite prints the address of your app:
VITE v8.3.8 ready in 106 ms
โ Local: http://localhost:5173/
โ Network: use --host to exposeOpen http://localhost:5173 in your browser. You'll see Vite's starter page with a counter button. Your React app is running.
Step 3: A quick tour of the files
todo-app/
โโโ index.html โ the one HTML page; has <div id="root">
โโโ package.json โ scripts and packages
โโโ vite.config.ts โ Vite settings (rarely touched)
โโโ tsconfig*.json โ TypeScript settings (already good)
โโโ public/ โ files served as-is (images, JSON)
โโโ src/
โโโ main.tsx โ starts React: draws <App /> into #root
โโโ App.tsx โ YOUR APP STARTS HERE
โโโ App.css โ styles for the starter page (we'll delete it)
โโโ index.css โ global styles
โโโ assets/ โ starter images (we'll delete them)Here's the file that starts everything. You'll rarely change it:
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)createRoot finds <div id="root"> in index.html, and React draws <App /> inside it.
Step 4: Make it yours
Delete src/App.css and the src/assets folder, and replace everything in src/App.tsx with this:
export default function App() {
const name = "Asha";
const tasksToday = 3;
return (
<main className="app">
<h1>Hello, {name}!</h1>
<p>You have {tasksToday} tasks today.</p>
<p>That's {tasksToday * 25} minutes of focused work.</p>
</main>
);
}Save. The browser updates by itself, without a reload. That's Vite's hot reload. Try changing the name and saving again.
For nicer styles, replace src/index.css with the course stylesheet. It only styles the To-Do app and isn't a React topic, so just copy it:
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #f4f6f8; color: #1f2937; }
.app { max-width: 480px; margin: 48px auto; padding: 24px; background: white; border-radius: 16px; box-shadow: 0 4px 24px rgb(0 0 0 / 0.08); }
h1 { margin-top: 0; }
.task-form { display: flex; gap: 8px; }
.task-form input { flex: 1; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px; }
button { padding: 8px 14px; border: 0; border-radius: 8px; background: #10b981; color: white; font-size: 15px; cursor: pointer; }
.filters { display: flex; gap: 6px; margin: 16px 0; }
.filters button { background: #e5e7eb; color: #374151; }
.filters button.selected { background: #1f2937; color: white; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.task label { display: flex; gap: 10px; align-items: center; }
.task.done span { text-decoration: line-through; color: #9ca3af; }
.task button { background: transparent; color: #9ca3af; }
.empty, .count, .tip { color: #6b7280; }
.tip.error { color: #dc2626; }The 6 JSX rules that trip up beginners
| Rule | Wrong | Right |
|---|---|---|
| Return one parent element | return <h1/><p/> | return <><h1/><p/></> |
| Use className, not class | <div class="app"> | <div className="app"> |
| Close every tag | <input> <br> <img src="a.png"> | <input /> <br /> <img src="a.png" /> |
| JavaScript goes in { } | <h1>name</h1> | <h1>{name}</h1> |
| Events are camelCase and take a function | onclick="save()" | onClick={save} |
| Components start with a capital letter | <taskItem /> | <TaskItem /> |
Commands you'll use
| Bun | npm | What it does |
|---|---|---|
| bun create vite app --template react-ts | npm create vite@latest app -- --template react-ts | Create a React + TypeScript app |
| bun install | npm install | Install the packages |
| bun run dev | npm run dev | Run the app with hot reload |
| bun run build | npm run build | Check types and build for the web (into dist/) |
| bun add <package> | npm install <package> | Add a package |
Key takeaways
- Vite creates and runs a React + TypeScript app in one command.
- Your code lives in src/, starting from App.tsx.
- JSX looks like HTML but follows a few JavaScript rules.
- Curly braces drop any JavaScript value into the page.
- Next: split the app into components and pass data with props.
Frequently asked questions
What is Vite?
Vite is the tool that runs your React app while you code (with instant updates when you save) and turns it into small, fast files for the web when you build it. It's the standard way to start a React project today.
Can I use npm instead of Bun?
Yes. Use npm create vite@latest todo-app -- --template react-ts, then npm install and npm run dev. Everything in the course works the same.
Why .tsx and not .jsx?
.tsx means TypeScript plus JSX. It's the same JSX you'd write in a .jsx file, with types on top so your editor catches mistakes like a misspelled prop.
Why className instead of class?
JSX becomes JavaScript, and class is a reserved word in JavaScript. So React uses className for CSS classes (and htmlFor instead of for on labels).
What is StrictMode?
A helper that only runs in development. It runs some code twice on purpose to help you spot bugs early. It does nothing in the finished app, so leave it on.
๐ง Quick check: setup and JSX
1. In which file do you write your app's main component?
2. How do you put a JavaScript value inside JSX?
3. Which is correct JSX?
4. A component returns two elements side by side. What do you wrap them in?