Create a Real React App
To build a real project on your computer, install Node.js (from nodejs.org), then create an app with Vite, a fast tool for starting React projects.
The examples in this course load React straight from the internet, which is great for learning but not for real projects. Real apps use a build tool that lets you split code into many files, import packages from npm, use JSX without extra setup, and create small, fast files for production.
Vite is today's popular choice: it starts in seconds and refreshes the browser instantly when you save. Frameworks built on React, like Next.js, add routing, server rendering and more for larger sites.
npm create vite@latest my-shop -- --template react
cd my-shop
npm install
npm run devOpen the address it prints (usually http://localhost:5173). Edit src/App.jsx and the page updates as soon as you save.
In a real project, import hooks at the top of the file:
import { useState } from "react";
export default function App() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>;
}What to learn next
- React Router for pages with different addresses.
- Loading data from an API with
fetchinsideuseEffect. - npm run build creates the final files to put on your website.
- Create real projects with
npm create vite@latest. - Import hooks from "react".
npm run devto develop,npm run buildfor the final files.
