Setting Up React with Vite
Vite is a tool that creates a ready React project. This course uses Vite 8.3.7 with React 19.3.1.
Check Node.js
This command prints the Node.js version.
node --versionCheck npm
This command prints the npm version.
npm --versionCreate the project
This command creates a project named my-react-app.
npm create vite@latest my-react-app -- --template reactExample
export default function App() {
return <h1>My React App</h1>
}Key points
- A project is a folder that holds all the files for one app.
- The create command asks Vite to build that folder for React.
- Node.js runs JavaScript outside the browser and Vite needs it.
- The version checks below confirm Node.js and npm are ready.
In this example, App is a JavaScript function. The function returns a heading. The heading reads My React App. Vite serves this file when the project runs.
Note
The create command is long. Copy it exactly and press Enter.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which command creates a new React project with Vite?