Quickstart
Get up and running with Vite in just a few minutes.Prerequisites
Scaffolding Your First Project
Use your preferred package manager to create a new Vite project:1
Run create-vite
Choose your package manager and run the create command:
2
Follow the prompts
You’ll be prompted to:
- Choose a project name
- Select a framework (React, Vue, Svelte, etc.)
- Pick a variant (JavaScript or TypeScript)
3
Install dependencies
Navigate to your project directory and install dependencies:
4
Start the dev server
Run the development server:Your app is now running at
http://localhost:5173!Using Command Line Options
You can also directly specify the project name and template via command line options. For example, to scaffold a Vite + React project:Available Templates
Vite supports a wide range of official templates:React templates come in two variants: standard (using Babel) and SWC (faster compilation). The
react-swc and react-swc-ts templates use SWC for faster builds.Manual Installation
If you prefer to set up Vite manually in an existing project:1
Install Vite
Add Vite as a dev dependency:
2
Create an index.html
Create an
index.html file in your project root:index.html
3
Create your source files
Create a
src/main.js file:src/main.js
4
Run Vite
Start the development server:Your app will be served at
http://localhost:5173!Understanding the Project Structure
index.html and Project Root
One thing you may have noticed is that in a Vite project,index.html is front-and-central instead of being tucked away inside public. This is intentional:
- During development Vite is a server, and
index.htmlis the entry point to your application - Vite treats
index.htmlas source code and part of the module graph <script type="module" src="...">references your JavaScript source code- Inline
<script type="module">and CSS via<link href>also enjoy Vite-specific features - URLs inside
index.htmlare automatically rebased - no need for special%PUBLIC_URL%placeholders
NPM Scripts
In a scaffolded Vite project, yourpackage.json will include these default scripts:
package.json
--port or --open:
package.json
npx vite --help in your project.
Community Templates
The officialcreate-vite templates are basic starting points. Check out Awesome Vite for community-maintained templates that include:
- Additional tools and configurations
- Different frameworks and libraries
- Full-stack setups
- Monorepo configurations
Try Vite Online
Want to try Vite without installing anything? Use StackBlitz:Vanilla JavaScript
Pure JavaScript starter
React
React with Fast Refresh
Vue
Vue 3 with SFC support
Svelte
Svelte with HMR
Next Steps
Now that you have a Vite project running, explore what you can do:Features
Discover Vite’s rich features
Configuration
Configure Vite for your needs
Plugins
Extend Vite with plugins