Starting a Project with Vite
A browser cannot read JSX, and a real app is made of dozens of files that need to be stitched together. Before you write a single component you need a tool that does that stitching for you, instantly, every time you save. Vite is the tool most new React projects start with.
The rule
Create, install, dev: three commands, then React is live.
Create generates a small, working project from a template:
npm create vite@latest reading-list -- --template react
cd reading-list
npm install
npm run devInstall (npm install) downloads everything listed in package.json, such as react and react-dom, into a node_modules folder.
Dev (npm run dev) starts a local development server, usually at http://localhost:5173. When you save a file, the change appears in the browser almost immediately, often without losing what was on screen.
The generated project is small enough to learn by heart:
reading-list/
index.html the one real HTML page, with <div id="root">
package.json dependencies and scripts
vite.config.js Vite settings (the React plugin lives here)
src/
main.jsx entry point: puts <App /> into #root
App.jsx your first componentThe entry point is short:
import { createRoot } from 'react-dom/client';
import App from './App.jsx';
createRoot(document.getElementById('root')).render(<App />);Files that contain JSX use the .jsx extension (or .tsx with TypeScript), which tells Vite to transform them into plain JavaScript the browser can run. Vite itself needs a recent version of Node.js installed; check with node --version if the create command complains.
When you are ready to publish, npm run build writes optimised, plain HTML, CSS and JavaScript into a dist folder that any static host can serve.