Language: JavaScript
Build Tool / Frontend
Vite was created by Evan You (the creator of Vue.js) to improve the frontend development experience by offering instant server start, fast hot module replacement (HMR), and an optimized build output. It supports frameworks like Vue, React, Svelte, and vanilla JavaScript projects.
Vite is a modern frontend build tool that provides a fast development server and optimized build process for modern web projects. It leverages native ES modules in the browser and bundles with Rollup for production.
npm create vite@latestyarn create vitepnpm create viteVite provides a development server with native ES module support and lightning-fast hot module replacement. For production builds, it uses Rollup to bundle and optimize assets. It supports plugins, TypeScript, JSX, CSS preprocessors, and framework-specific configurations.
# Terminal
npm create vite@latest my-vite-app
cd my-vite-app
npm install
npm run devInitializes a new Vite project, installs dependencies, and starts the development server.
// main.js
import { hello } from './module.js';
hello();Demonstrates importing a module using native ES module syntax in a Vite project.
# Terminal
npm create vite@latest my-react-app --template react
cd my-react-app
npm install
npm run devCreates a React project preconfigured with Vite and starts the dev server with fast HMR.
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: { port: 3000 },
});Configures Vite to use the React plugin and run the dev server on port 3000.
npm run build
# Output is in dist/ folderGenerates an optimized production build using Rollup.
// vite.config.js
import vue from '@vitejs/plugin-vue';
export default {
plugins: [vue()]
};Demonstrates adding a Vite plugin for Vue support.
Use ES modules and modern JavaScript syntax for better performance.
Take advantage of Vite's HMR during development for instant feedback.
Use plugins for framework-specific features and optimizations.
Keep configuration minimal; Vite works with zero-config for many projects.
Use environment variables and .env files to manage project settings.