Below is the quickest, cleanest way to spin up a brand-new Vite project that has zero “big” framework code (no React, Vue, Svelte, etc.)—just plain HTML, CSS and JavaScript (or TypeScript, if you prefer).
1. Prerequisites
Node ≥ 18 (LTS is recommended).
Check with:
bash
node -v
npm -v # or: pnpm -v / yarn -v
2. Scaffold the project
Option A – JavaScript (default)
bash
# ① Run the official Vite scaffolder (no global install needed)
npm create vite@latest my-app -- --template vanilla
# └────┬────┘ └────────────── template name
# | (“vanilla” = plain JS)
# └ The folder you want to create
npm create is just sugar over npx create-vite, feel free to swap in pnpm create or yarn create.
3. Install dependencies & run dev server
bash
cd my-app
npm install # brings in vite itself
npm run dev # launches Vite’s dev server
⬆️ You’ll see something like:
code
VITE vX.X.X ready in 300 ms
➜ Local: http://localhost:5173/
Open that URL and you should see Vite’s default “Hello Vite!” page. Hot-module-replacement (HMR) is already wired up, so edits save-and-refresh instantly.
4. Project anatomy (after scaffolding)
code
my-app
├─ public/ # static assets copied as-is
│ └─ favicon.svg
├─ index.html # entry HTML
├─ src/
│ ├─ main.js # or main.ts
│ └─ style.css
├─ package.json
└─ vite.config.js # optional, not created by default
Key things to know
index.html lives in the project root, not /public. During dev it’s served as is; during build it’s transformed and minified.
Import any assets in your JS/TS/CSS. Vite will hash them on production build:
js
import logo from './assets/logo.png';
Anything inside public/ is copied verbatim to /dist.
5. Common next steps
Task
How
Add an NPM dependency
npm i lit (or lodash, anime.js, whatever) — Vite auto-bundles it
Write modern CSS
Use PostCSS plugins, Tailwind, etc. npm i -D tailwindcss postcss autoprefixer then configure
Environment variables
Create .env, .env.prod… access through import.meta.env.VITE_MY_KEY
Absolute import aliases
vite.config.js ➜ resolve.alias: { '@': '/src' }
Build for production
npm run build ➜ output in dist/
Preview prod build
npm run preview
6. Minimal vite.config.js (only if you need it)
js
// vite.config.js
import { defineConfig } from 'vite';
export default defineConfig({
base: './', // useful when deploying into a subfolder
server: {
port: 3000,
open: true
},
build: {
outDir: 'dist'
}
});
If you’re happy with the defaults, you can omit this file entirely.
7. Deploying
Vite outputs static files, so you can deploy /dist to:
GitHub Pages
Vercel / Netlify
Firebase Hosting
Cloudflare Pages
Any S3 bucket, nginx, Apache, etc.
🎉 That’s all you need to kick off a vanilla Vite project—fast dev server, ES modules, HMR and an optimized production build with zero framework boilerplate. Happy hacking!