Skip to content

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();
}),
},
}
}
});