Generating OG Images
A guide from Supabase
Apps on Plentiful run on Supabase's open-source database, sign-in, file storage and live updates, so most of this guide applies. The differences: your app reaches its database through its own server — not Supabase's data API (supabase.from(…)) — there are no Edge Functions (your app's server does that work), and scheduled work uses Jobs. Where it says "Supabase dashboard", use your app's Dashboard. Ask the builder when in doubt.
Generate Open Graph images with Deno and Supabase Edge Functions. View on GitHub.
Code#
Create a handler.tsx file to construct the OG image in React:
1import React from 'https://esm.sh/react@18.2.0'2import { ImageResponse } from 'https://deno.land/x/og_edge@0.0.4/mod.ts'34export default function handler(req: Request) {5 return new ImageResponse(6 <div7 style={{8 width: '100%',9 height: '100%',10 display: 'flex',11 alignItems: 'center',12 justifyContent: 'center',13 fontSize: 128,14 background: 'lavender',15 }}16 >17 Hello OG Image!18 </div>19 )20}Create an index.ts file to execute the handler on incoming requests:
1import handler from './handler.tsx'23console.log('Hello from og-image Function!')45Deno.serve(handler)