Skip to main content

What is HMR?

HMR (Hot Module Replacement) is a mechanism that lets you update changed application modules without a full page reload. When code changes, only the needed fragment is rebuilt, and the browser swaps it in the running application on the fly.

What HMR gives you:

  1. Preserving state - the interface is not reset on update (unlike regular Live Reload).
  2. Fast feedback - changes are instantly visible in the browser.
  3. Faster development - not the whole project is rebuilt, only the changed module.

How it works under the hood:

  • the dev server tracks changes,
  • the updated module is sent over WebSocket,
  • the Vite runtime replaces only the changed module inside the application.

The essence: HMR updates code precisely, without reloading the whole page and without losing the application's current state.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.