Installing and Scaffolding a Vite Project
You'll learn how to create a new Vite project from scratch and understand the initial folder structure it generates.
Setting Up Your First Vite Project
Now that you understand what Vite is and how it leverages native ESM, it's time to actually create a project. Vite provides a scaffolding tool called create-vite that sets up everything you need with a single command.
Think of scaffolding like getting a pre-furnished apartment instead of an empty room. You don't start from nothing—Vite gives you a working structure with sensible defaults.
The Installation Command
To create a new Vite project, run one of these commands in your terminal:
npm create vite@latest my-project-name
or with other package managers:
yarn create vite my-project-name
pnpm create vite my-project-name
You'll be prompted to choose a framework (vanilla JavaScript, React, Vue, etc.) and a variant (JavaScript or TypeScript). For learning Vite itself, start with vanilla JavaScript.
Understanding the Generated Structure
After scaffolding, you'll see a folder structure like this:
index.html- Your entry point (lives at the root, not in a public folder!)package.json- Project dependencies and scriptsvite.config.js- Vite configuration (optional, often minimal)src/- Your application codepublic/- Static assets that bypass Vite processing
The most unusual thing: index.html is the entry point, not buried in a public folder. This is intentional—Vite treats HTML as part of your module graph.
Key Takeaway: Use create-vite to scaffold projects quickly with an intelligent default structure where index.html serves as the main entry point and references your JavaScript modules directly.