Getting Started Lesson 2 of 13
Getting Started with React — Vite, Node.js and Project Structure
Set up a real React project with Node.js and Vite, understand the main files (index.html, main.jsx, App.jsx), run the development server, and build for production.
The examples in this course run directly in the browser. For your own projects, the standard setup is Node.js plus a build tool called Vite, which gives you instant reloads and an optimized final website.
Step 1: Install Node.js
Download the LTS version from nodejs.org and install it. Then check in a terminal:
node -v
npm -v
Output
v22.11.0 10.9.0
npm (Node Package Manager) comes with Node.js and installs libraries like React.
Step 2: Create a React project with Vite
npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev
Output
VITE v6.0.0 ready in 312 ms ➜ Local: http://localhost:5173/
Open http://localhost:5173. Edit src/App.jsx, save, and the browser updates instantly.
The important files
my-app/
├── index.html the single HTML page, with <div id="root">
├── package.json project info and dependencies
└── src/
├── main.jsx starts React and renders <App />
├── App.jsx your main component
└── App.css styles
src/main.jsx:
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.jsx";
createRoot(document.getElementById("root")).render(
<StrictMode>
<App />
</StrictMode>
);
src/App.jsx:
import { useState } from "react";
export default function App() {
const [count, setCount] = useState(0);
return (
<main>
<h1>Hello, React!</h1>
<button onClick={() => setCount(count + 1)}>Clicked {count} times</button>
</main>
);
}
In real projects, each component lives in its own file and is shared with export and import. In this course's live examples, everything is in one <script> and we get hooks with const { useState } = React; instead of import.
Step 3: Build for the web
npm run build
This creates a dist folder with small, optimized HTML, CSS and JavaScript files. Upload that folder to any static host such as Vercel, Netlify or GitHub Pages.
Useful tools
- VS Code with the ES7+ React snippets extension.
- React Developer Tools browser extension: inspect components, props and state.
The template used in this course
Every live example follows this pattern, which you can also save as an .html file and open directly in a browser:
<div id="root"></div>
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
function App() {
return <h1>Hello!</h1>;
}
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
</script>
It's perfect for learning, but too slow for real websites, because Babel translates the code in every visitor's browser.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04