Custom OG Middleware Handler

Oct 4 recipes

Friday internally uses @vercel/og as the OG image generation tool.

When you need to deploy to environments other than Node.js, for better compatibility, it’s recommended to use the corresponding runtime’s OG generation middleware.

Taking Cloudflare Worker as an example, you can do this (for how to deploy Astro to Cloudflare, we won’t elaborate here):

npm i @cloudflare/pages-plugin-vercel-og
// astro.config.ts
import friday from 'astro-friday'
import { defineConfig } from 'astro/config'

export default defineConfig({
  integrations: [
    friday({
      // ...
      imports: {
        '@vercel/og': '@cloudflare/pages-plugin-vercel-og/api',
      },
    }),
  ],
})