OG from Database
Seed/list Neon product rows (or in-memory fallback) and render ImageResponse OG cards by slug.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/og-from-database pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects.
OG from Database seeds product rows into Neon (experiment_products) when DATABASE_URL is set, otherwise uses an in-memory seed list. GET /api/og?slug= looks up the row and returns an ImageResponse card from title/description. No AI provider is required.
Features
- Seed / list / upsert products – Neon or in-memory.
- OG by slug –
ImageResponsefrom row fields. - Shared memory store – in-memory adds appear in OG previews.
- Sample catalog – Edge Cache Kit, Neon Notes, Blob Drop.
- Honest storage note when Postgres is missing.
API Reference
GET /api/products / POST /api/products
List or upsert { slug?, title, description }.
GET /api/og?slug=
Returns a 1200×630 PNG Open Graph image for the product.
| Status | Cause |
|---|---|
400 | Missing slug / invalid product body |
404 | Unknown slug |
Implementation Details
ensureTable + seedIfEmpty
Creates experiment_products and seeds defaults once.
ImageResponse
Renders title + description from the looked-up row.
Use Cases
- Learn composition patterns for this lab’s stack.
- Prototype before wiring production auth and quotas.
- Deploy the standalone app as a reference implementation.
Limitations
- Demo-scale caps on input size and output counts.
- No auth / rate limits on public deploys.
- Model quality depends on input clarity.
Use in your project
Copy the Route Handler and logic.ts helpers from apps/experiments/og-from-database/. Wire your own persistence and auth as needed.
Deployment
Local Development
cd apps/experiments/og-from-database
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
DATABASE_URL | No | Neon product storage |
Vercel / Next.js Features Used
next/ogImageResponse- Neon serverless Postgres
- Route Handlers
- Zod