Back to Snowpack

Hot Module Replacement (HMR) API

docs/reference/hot-module-replacement.md

3.8.5520 B
Original Source

Snowpack implements HMR via the esm-hmr spec, an attempted standard for ESM-based Hot Module Replacement (HMR).

js
// HMR Code Snippet Example
if (import.meta.hot) {
  import.meta.hot.accept(({module}) => {
    // Accept the module, apply it into your application.
  });
}

Full API Reference: snowpack/esm-hmr on GitHub

Learn more about HMR, Fast Refresh, and how it's meant to work in Snowpack.