Home / React / Lesson 2

Set up React with Vite

Beginner 9 min read Lesson 2 of 11

You need Node.js LTS installed (node -v should print a version). npm comes with it.

Create the project

In a terminal, in a folder you own:

npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev

Vite prints a local URL (usually http://localhost:5173). That command is the official Vite React template. Do not use npx create-react-app — CRA is unmaintained.

What the files are

Build for production

npm run build writes static files to dist/. You can host that folder on GitHub Pages, Netlify or Vercel — see host a site free.

If npm create vite fails, your Node version is too old, or you are offline. The template name react is JavaScript; react-ts adds TypeScript. This course uses JavaScript.