Astro Integration Kit (AIK) is a utility package designed to simplify and streamline the development of Astro integrations. Currently stable at version 0.20.0, the library is actively maintained with minor versions released periodically, often to align with new Astro releases and introduce new features or refinements. AIK provides a high-level API to abstract away common complexities of the Astro Integration API, such as managing Vite plugins, generating virtual modules, and resolving paths. It aims to make building robust and performant community-driven Astro integrations more accessible, differentiating itself by offering a structured and less verbose approach compared to interacting directly with Astro's lower-level integration hooks. The project has a clear upgrade guide detailing breaking changes across versions, indicating continuous evolution and improvement to keep pace with the Astro ecosystem.
npm install astro-integration-kitVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates defining a basic Astro integration using `defineIntegration` with a Zod schema for options. It conditionally adds a Vite plugin during `astro:config:setup` and logs a message on build completion.
Review the 'Upgrade guide' (e.g., for v0.16.0, v0.15.0, v0.13.0, v0.12.0, v0.11.0, v0.10.0, v0.9.0, v0.8.0) and adapt your integration code accordingly. Key changes have included renaming utilities, refactoring plugin APIs, and updating hook return types.
`watchIntegration` was renamed to `watchDirectory` in v0.10.0. `addDevToolbarFrameworkApp` and `addDts` were removed in v0.12.0, requiring alternative approaches for those functionalities. Refer to the upgrade guide for migration details.
Ensure your Node.js version is compatible with your Astro installation. Astro 4.x/5.x/6.x generally requires Node.js 18.17.1+ or 20.3.0+. Update your Node.js environment to a supported LTS version (e.g., 20.x or 22.x).
Run `npm install astro-integration-kit` or `pnpm add astro-integration-kit` to install the package. Ensure your `tsconfig.json` includes `node_modules` in its `typeRoots` if using TypeScript.
Ensure your integration file uses `export default defineIntegration(...)` rather than named exports or direct function exports.
Ensure that any code interacting with browser APIs is guarded (e.g., `if (typeof window !== 'undefined') { ... }`) or is explicitly marked for client-side execution, which is generally handled by the Astro components themselves, not typically within integration setup.