I was doing a Vite demo last week, I changed some markup, and visited the local web server. The markup changed, but the state persisted. What?!

This is Vite’s Hot Module Replacement API.

The Vite React application server logged this when I saved my file:

9:32:15 AM [vite] (client) hmr update /src/App.tsx

“hmr” is Hot Module Replacement. With it, we get “precise updates without reloading the page or blowing away application state.” So cool!

HMR API docs