Skip to content

Getting Started

Add the desired plugins (or all plugins) to your defineIntegration call:

your-integration.ts
import { defineMiddlewarePlugin } from '@inox-tools/aik-mod';
export default defineIntegration({
name: 'your-integration',
plugins: [defineMiddlewarePlugin],
setup: () => ({
'astro:config:setup': ({ defineMiddleware }) => {
defineMiddleware('pre', (context, next) => {
// Your inline middleware
return next();
});
},
}),
});

API

Each functionality is provided as a separate AIK plugin that you can use.

All of them accept normal values and factory wrappers as values to be included in the virtual modules.

inlineModule

inlineModule allows you to define a module inline, returning the name of the defined module.

It receives the definition of the virtual module.

my-integration.ts
import { defineIntegration } from 'astro-integration-kit';
import { inlineModulePlugin } from '@inox-tools/aik-mod';
export default defineIntegration({
name: 'my-integration',
plugins: [inlineModulePlugin],
setup(options) {
return {
'astro:config:setup': ({ inlineModule }) => {
const moduleName = inlineModule({
defaultExport: 'some value',
constExports: {},
assignExports: {},
});
},
};
},
});

defineModule

defineModule allows you to define a module inline with a given import name.

It receives the definition of the virtual module.

my-integration.ts
import { defineIntegration } from "astro-integration-kit";
import { defineModulePlugin } from "@inox-tools/aik-mod";
export default defineIntegration({
name: "my-integration",
plugins: [defineModulePlugin],
setup(options) {
return {
"astro:config:setup": ({ defineModule }) => {
defineModule('virtual:my-integration/module', {
defaultExport: 'some value',
constExports: {},
assignExports: {},
});
},
}
}
});

defineMiddleware

defineMiddleware allows you to define an Astro middleware inline.

my-integration.ts
import { defineIntegration } from "astro-integration-kit";
import { defineMiddlewarePlugin } from "@inox-tools/aik-mod";
export default defineIntegration({
name: "my-integration",
plugins: [defineMiddlewarePlugin],
setup(options) {
return {
"astro:config:setup": ({ defineMiddleware }) => {
defineMiddleware('pre', (context, next) => {
// This runs in the Astro middleware
return next();
});
},
}
}
});