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
1
import {
2
defineIntegration,
3
addIntegration
4
} from "astro-integration-kit";
5
import Vue from "@astrojs/vue";
6
7
export default defineIntegration({
8
// ...
9
setup() {
10
return {
11
hooks: {
12
"astro:config:setup": (params) => {
13
addIntegration(params, {
14
integration: Vue()
15
})
16
}
17
}
18
}
19
}
20
})

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
1
addIntegration(params, {
2
integration: Vue(),
3
ensureUnique: false
4
})