Skip to content

hmrIntegration

hmrIntegration enables hot module reloading (HMR) for your integration during development. This is meant to work with a monorepo setup where you have a package/ and playground/. It watches a directory (or directories) and triggers Astro dev server reloads when files change, keeping feedback fast and automatic.

hmrIntegration uses watchDirectory under the hood to monitor your integration’s build output directory. When a file changes, the Astro dev server reloads so you can immediately see the effect—no manual restarts needed.

playground/astro.config.mjs
import { defineConfig } from "astro/config";
import { importFresh, hmrIntegration } from "astro-integration-kit/dev";
const { default: myIntegration } = await importFresh<typeof import("my-integration")>("my-integration");
export default defineConfig({
integrations: [
myIntegration(),
hmrIntegration({ directory: "../package/dist" })
],
});

Pass either directory or directories to specify what to watch for changes:

hmrIntegration({ directory: "../package/dist" })
hmrIntegration({ directories: ["../package/dist", "../other-dir"] })