How to create vite app project
1. Install Node.js
Make sure you have Node.js installed. You can check if Node is installed by running:
node -v
If it’s not installed, download and install the latest version from the Node.js website.
2. Create a Vite Project
Vite provides a simple command-line tool to scaffold a new project.
Using npm:
-
Run the following command:
npm create vite@latest
-
Provide a project name (or leave blank for the default
vite-project
). -
Select a framework: You’ll be prompted to choose a framework (e.g., React, Vue, Svelte, etc.). Select one, such as React, if you are building a React app:
Vanilla
Vue
React
Svelte
Preact
Lit
Solid
Optionally, choose the variant (TypeScript, JavaScript).
Example for React + TypeScript:
✔ Project name: … my-vite-app ✔ Select a framework: › React ✔ Select a variant: › React + TypeScript
-
Navigate into the project folder:
cd my-vite-app
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
The Vite app should now be running locally at
http://localhost:5173
.
Using yarn:
yarn create vite
3. Build for Production
When you’re ready to build the app for production, you can run:
npm run build
This will generate the optimized production build in the dist
folder.
4. Preview the Production Build
To preview the build, use:
npm run preview
That’s it! You’ve created a Vite project!