Vite’s Dev Server: Instant Cold Starts and Sub‑100 ms Hot Reloads
Vite’s dev server serves native ES modules, delivering sub‑100 ms hot reloads and near‑instant cold starts without a full bundle.
21 Nov 2025, 20:32 UTC

Instant Cold Starts and Sub‑100 ms Hot Reloads: The Vite Advantage
When you run a typical React or Vue app with Webpack, the first page load can take several seconds because the bundler must parse, transform, and bundle every file before the browser even sees any code. Vite flips that script: its dev server serves each source file as a native ES module, so the browser can request the file directly and execute it instantly. In practice this means a cold start of less than 500 ms on a typical laptop and hot reloads that feel faster than 100 ms after the first change.
How Vite Serves Native ES Modules
Vite’s dev server is built on esbuild for fast transpilation, but it does not bundle the app during development. Instead, it starts a lightweight HTTP server that maps each .js, .ts, .vue file to its original location on disk. The browser’s <script type="module"> tag then fetches the file over HTTP, and the browser’s native ES module loader handles parsing and execution. Because the module is loaded directly, there is no need for a separate bundle step, which eliminates the “cold start” latency that Webpack experiences.
Hot Module Replacement (HMR) works by watching the file system for changes. When a file changes, Vite sends only that file’s updated text to the browser, which replaces the module’s state without reloading the whole page. In most scenarios the round‑trip and patching happen well under 100 ms, giving the impression of an instantaneous refresh.
Verifying the Experience in Your Project
- Run the official starter:
npm create vite@latest my-app --template react. This command scaffolds a new project with the requiredpackage.jsonand avite.config.jsthat leaves the default settings untouched. - Start the dev server with
npm run dev. The script runsvite, which prints something likevite v5.0.0and indicates that the server is listening onhttp://localhost:5173. - Open Chrome DevTools, switch to the Network tab, and reload the page. You should see a separate request for each source file (e.g.,
src/App.jsx,src/main.jsx) with a status of 200. No bundled file such asbundle.jsappears. - Edit a component, save the file, and watch the console. A message like
Fast Refresh: module replacedappears, and the UI updates instantly without a full page reload.
These steps confirm that the server is indeed serving native modules and that HMR is active.
When Vite’s Approach Hits Limits
Native ES modules require browsers that support them. Older browsers such as Internet Explorer 11 or early versions of Safari cannot load <script type="module"> tags, so users on those platforms will see a blank page unless you build a fallback bundle for production. In a monorepo with dozens of inter‑dependent packages, the dev server must serve many files individually, which can increase the cold‑start time, especially on slower machines. Additionally, packages that rely on non‑standard resolution fields (e.g., browser or main entries) may need the type: module flag or a manual optimizeDeps override to work correctly.
Worked Example: A Minimal React Component
// src/App.jsx
import React, { useState } from 'react';
export default function App() {
const [count, setCount] = useState(0);
return (
Vite Demo
setCount(c => c + 1)}>
Clicked {count} times
);
}
After creating the project as described above, run npm run dev and open http://localhost:5173. Changing the setCount line or the button text triggers HMR: the browser receives only the updated App.jsx file, patches the component state, and the UI updates instantly. The Network tab shows a single request for App.jsx with a 200 status, confirming that no full bundle was rebuilt.
Trade‑off: Development Speed vs. Production Build Complexity
While Vite delivers an ultra‑fast dev experience, the production build still uses Rollup (or another bundler) to create an optimized bundle that supports older browsers. This means you still need a separate build step, and the configuration for output formats, code splitting, and asset handling is similar to other modern bundlers. The key difference is that the heavy lifting happens only once, during the production build, not on every code change during development.
Actionable Closing
If you want instant cold starts and sub‑100 ms hot reloads, adopt Vite for your next front‑end project. Start with the official template, verify the native‑module behavior using the steps above, and be aware of the browser support and monorepo considerations. When you’re ready for production, run npm run build to generate a traditional bundle that works everywhere, then deploy the output as usual.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.