Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 38 ยท Getting Started

What Is Vite?

Learn what Vite is, why it starts instantly, how its dev server and production build differ, and what problems a front-end build tool solves for modern web projects.

Vite (French for "fast", pronounced like "veet") is a build tool and development server for front-end projects. You give it an index.html and some JavaScript, TypeScript, CSS or framework files, and it serves them to your browser while you work and bundles them into small, optimized files when you are ready to ship. It was created by Evan You, the author of Vue, in 2020, and it now powers projects built with React, Vue, Svelte, Solid, Preact, Lit and plain JavaScript.

The idea behind Vite is simple: a modern browser already understands import and export. So during development Vite does not need to glue your whole app into one giant file before showing anything. It serves your files as they are, transforms only what the browser cannot read (like TypeScript or JSX), and lets the browser do the rest. The result is a dev server that starts in well under a second, even on a large project.

Vite is not installed on this site, so Vite commands and config files in this course are read-only code blocks. Runnable examples are small Node.js or browser programs that reproduce the ideas Vite relies on (module resolution, URL handling, caching). Each one is labelled as a stand-in.

The problem a build tool solves

A real web app is not one file. It has hundreds of modules, packages from npm, TypeScript, CSS preprocessors, images and fonts. Browsers cannot resolve a bare import such as import { ref } from 'vue', because they do not know where vue lives. They cannot read .tsx. They would also have to download hundreds of tiny files for a production page, which is slow.

A build tool bridges those gaps. It must:

  • Resolve bare imports to real files.
  • Transform source code that browsers cannot run (TypeScript, JSX, Vue single-file components, Sass).
  • Serve the result quickly while you edit, and update the page when you save.
  • Bundle and minify everything for production, with caching-friendly file names.

Older tools did all of this by bundling the entire app before the dev server could answer its first request. The bigger the app, the longer you waited.

Two modes, two engines

Vite behaves differently in development and in production, and that is the secret to both its speed and its output quality.

What Vite does

Instant dev server Serves source as native ES modules
Fast HMR Updates one module, not the app
Optimized build Bundles, minifies, splits code
Plugin system Extend it with a simple API

Same config drives development and production.

1 / 3

In development, the browser asks for /src/main.js; Vite sends it, rewriting import paths on the way. The browser sees import './App.vue' and asks for that file; Vite compiles it on the spot and replies. Files nobody visits are never processed. Packages from node_modules are converted once into a few efficient files (called dependency pre-bundling, covered in Dependency Pre-Bundling) and cached.

In production, Vite hands your project to a bundler that is good at producing small output: Rollup in Vite 5 and 6, and the Rust-based Rolldown in newer major versions. It joins modules, removes unused code, splits chunks and adds content hashes to file names so browsers can cache them for a long time.

flowchart LR
  A["index.html + src/*"] --> B{"Command"}
  B -->|"vite (dev)"| C["Dev server: native ESM"]
  C --> D["Browser requests modules one by one"]
  B -->|"vite build"| E["Bundler: Rollup / Rolldown"]
  E --> F["dist/: minified, hashed files"]

The same project and config feed both paths.

What you get without configuring anything

Out of the box Vite understands:

  • ES modules, JSON and CSS imports.
  • TypeScript: .ts files are transpiled (types are stripped, not checked).
  • JSX and TSX for frameworks that use them.
  • CSS Modules, PostCSS and (once the preprocessor is installed) Sass, Less and Stylus.
  • Static assets such as images and fonts, with URL handling and hashing.
  • Environment variables from .env files.
  • Hot Module Replacement (HMR), where a saved edit updates the page without a reload.

Framework features come from plugins, such as @vitejs/plugin-react or @vitejs/plugin-vue, and you add them in one config file (see The Vite Config File).

Why bare imports need help: a stand-in

The first job in the list above, resolving bare imports, is easy to see in miniature. Browsers resolve only relative or absolute URLs. This stand-in shows the rewrite Vite performs during development. It is a simplified model, not Vite's real code.

Node.js Stand-in: rewriting bare imports

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The output shows 'vue' replaced by a real URL while ./App.vue is left alone, and an unknown package fails with a message much like the one you will see in a real project.

Where Vite sits in your stack

Vite is not a framework. It does not decide how you render pages, manage state or fetch data. It is the layer underneath: you pick React or Vue or nothing, and Vite makes that code run in the browser and ship efficiently. Some meta-frameworks build on it (SvelteKit, Nuxt, Astro, Remix and React Router in framework mode, SolidStart) and use its plugin API, so Vite knowledge carries over. The Frameworks and SSR chapter later in the course (see the track page) covers that.

What Vite is not

  • Not a type checker. It strips TypeScript types for speed. Run tsc --noEmit for checking.
  • Not a test runner. It pairs with Vitest, a test runner that reuses your Vite config.
  • Not a package manager. You still use npm, pnpm, Yarn or Bun to install packages.
  • Not magic for old browsers. The default build targets modern browsers; legacy support is opt-in with a plugin.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does the Vite dev server start so quickly?

    Vite does not bundle before serving. The browser requests each module, and Vite transforms only the files that are actually requested.
  2. 2. Which task does the Vite production build perform?

    The build hands your code to a bundler (Rollup or Rolldown) to produce optimized files in dist/. Tests, installs and type checks are separate tools.
  3. 3. What is true about TypeScript in Vite?

    Vite only transpiles TypeScript. Type checking is left to tsc or your editor.
  4. 4. Why can a browser not run import { ref } from 'vue' directly?

    Browsers only resolve relative and absolute URLs. A tool must rewrite bare specifiers to real paths, which Vite does during development.

Summary

  • Vite is a front-end build tool with a fast dev server and an optimized production build.
  • Development serves native ES modules and transforms files on demand; production bundles with Rollup or Rolldown.
  • It supports TypeScript, JSX, CSS, assets, env variables and HMR out of the box; frameworks arrive through plugins.
  • It strips TypeScript types but does not check them, and it is not a test runner or package manager.
  • Meta-frameworks such as SvelteKit, Nuxt and Astro build on top of Vite.

Next: Create Your First Vite Project