To start a project with Vite without using any specific front-end framework (like React, Vue, etc.), you can set up a vanilla JavaScript project. Vite supports vanilla JS out of the box.
Here’s a step-by-step guide to help you get started:
✅ 1. Prerequisites
Make sure you have Node.js and npm (or yarn) installed.
Check with:
node -v
npm -v
✅ 2. Create a new Vite project
Use the following command:
npm create vite@latest
You’ll be prompted to:
- Project name: Enter a name, e.g.,
my-vite-app
- Select a framework: Choose
Vanilla
- Select a variant: Choose
JavaScript (or TypeScript if you prefer)
Alternatively, you can do everything in one command:
npm create vite@latest my-vite-app -- --template vanilla
✅ 3. Navigate to the project directory
cd my-vite-app
✅ 4. Install dependencies
npm install
✅ 5. Start the development server
npm run dev
This will start the Vite dev server and provide a local URL (usually http://localhost:5173) to open in your browser.
✅ 6. Project Structure
The default project structure looks like:
my-vite-app/
├── index.html
├── main.js
├── style.css
├── package.json
└── vite.config.js
index.html: The main HTML entry
main.js: The JavaScript entry file
style.css: A default stylesheet (optional)
vite.config.js: Vite configuration (optional for now)
package.json: Project dependencies and scripts
✅ 7. Build the project
To create a production build:
npm run build
The build files will be generated in the dist/ directory.
To preview the build locally:
npm run preview
✅ 8. Optional: Customize config
You can configure Vite further by editing vite.config.js. Here's a basic example:
// vite.config.js
export default {
root: './', // project root
build: {
outDir: 'dist', // output directory
},
};
🎉 Done!
You now have a fast and minimal development setup with Vite using plain JavaScript — no framework required.
Let me know if you want to add TypeScript or anything else!