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:
- Preserving state - the interface is not reset on update (unlike regular Live Reload).
- Fast feedback - changes are instantly visible in the browser.
- 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 readyPremium
A concise answer to help you respond confidently on this topic during an interview.