Skip to content

addIntegration

addIntegration allows you to add an integration from within an integration.

It will also do a check using hasIntegration to check whether the integration you’re trying to add has already been added. If it has, it won’t add it again.

my-integration/index.ts
import { defineIntegration } from "astro-integration-kit";
import { addIntegrationPlugin } from "astro-integration-kit/plugins";
import Vue from "@astrojs/vue";
export default defineIntegration({
name: "my-integration",
plugins: [addIntegrationPlugin],
setup(options) {
return {
"astro:config:setup": ({ addIntegration }) => {
addIntegration(Vue())
}
}
}
})

Ensuring unique integrations

By default addIntegration will fail if you try to add an integration that’s already been added.

You can bypass this and add it anyway with the ensureUnique flag.

integration.ts
addIntegration(Vue(), {
ensureUnique: false
})