astro/.changeset/chilly-pants-fix.md
Emanuele Stoppa 9e5fafa2b2
feat: vercel edge middleware support (#7532)
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-07-05 16:45:58 +01:00

594 B

astro
minor

Astro exposes the middleware file path to the integrations in the hook astro:build:ssr

// myIntegration.js
import type { AstroIntegration } from 'astro';
function integration(): AstroIntegration {
    return {
        name: "fancy-astro-integration",
        hooks: {
            'astro:build:ssr': ({ middlewareEntryPoint }) => { 
                if (middlewareEntryPoint) {
                    // do some operations
                }
            }
        }
    }
}

The middlewareEntryPoint is only defined if the user has created an Astro middleware.