Before we begin, make sure you have the following installed:
Open your terminal and run the following command to scaffold a new Vite + React project:
npm create vite@latest my-react-app -- --template react
Or with Yarn:
yarn create vite my-react-app --template react
Replace
my-react-app
with your desired project name.
After the project is scaffolded:
cd my-react-appnpm install
Or with Yarn:
cd my-react-appyarn
To start the dev server:
npm run dev
Or:
yarn dev
Youβll see something like this:
VITE vX.X.X ready in XXX msβ Local: http://localhost:5173/
Open that URL in your browser to see your new React app in action!
When youβre ready to deploy, build the optimized production version:
npm run build
This will create a dist/
folder containing the static files.
To preview the production build locally:
npm run preview
Vite gives you a clean and minimal setup. Hereβs what your folder structure looks like:
my-react-app/βββ node_modules/βββ public/β βββ vite.svgβββ src/β βββ App.cssβ βββ App.jsxβ βββ index.cssβ βββ main.jsxβββ index.htmlβββ package.jsonβββ vite.config.jsβββ README.md
If you prefer TypeScript:
npm create vite@latest my-react-app -- --template react-ts
Or:
yarn create vite my-react-app --template react-ts
Now that your React app is up and running, here are a few things you can do next:
Quick Links
Legal Stuff
Social Media