We use Vite (pronounced “veet”) as the build tool. It’s fast, simple, and the recommended way to start React projects.
Copy
npm create vite@latest my-react-app -- --template reactcd my-react-appnpm installnpm run dev
Your app is now running at http://localhost:5173. Every time you save a file, the browser updates instantly.
Vite is to JavaScript what FastAPI is to Python — the modern, fast, no-nonsense choice. It replaces the older Create React App (CRA), which is no longer recommended.
my-react-app/├── node_modules/ # Dependencies (don't edit)├── public/ # Static files (images, favicon)├── src/│ ├── App.jsx # Your main component│ ├── App.css # Styles for App component│ ├── main.jsx # Entry point — renders App into the DOM│ └── index.css # Global styles├── index.html # The single HTML page├── package.json # Dependencies and scripts└── vite.config.js # Vite configuration
src/main.jsx — The entry point. Renders your App component into the root div.
Copy
import React from 'react';import ReactDOM from 'react-dom/client';import App from './App.jsx';import './index.css';ReactDOM.createRoot(document.getElementById('root')).render( <React.StrictMode> <App /> </React.StrictMode>);
React.StrictMode is a development-only helper. It may render components (and run effects) more than once in development to help catch bugs. This can look surprising at first, but it does not happen in production builds.
src/App.jsx — Your main component. This is where you start building.
Start by editing App.jsx. Delete the default content and replace it with your own. You’ll add more components as files in the src/ folder and import them into App.jsx.
React files use .jsx instead of .js. JSX lets you write HTML-like syntax inside JavaScript — you’ll learn more in the next lesson.
Copy
// This is JSX — HTML inside JavaScriptfunction Greeting() { return <h1>Hello, World!</h1>;}
.jsx and .js both work in Vite. The convention is .jsx for files that contain JSX (which is almost every React file). Some projects use .tsx for TypeScript + JSX.
Don’t over-organize early. Start with all components in src/, and extract into folders when you have 10+ files. The folder structure isn’t enforced by React — use whatever makes sense for your project.