๐ Hey DEV community!
Iโm excited to share Dynamic OG Image Generator, an open-source project I built to simplify generating dynamic Open Graph images for blogs, apps, and social media. It leverages Cloudflare Workersโ edge network for blazing-fast performance, and Iโd love your feedback (and a star โญ)!
The Problem
Social platforms like Twitter and LinkedIn rely on Open Graph images for rich link previews. But:
- Static images get stale quickly
- Dynamic solutions often require complex backends or paid services
- Font/licensing issues can derail designs
This project solves those pain points with edge computing and flexible customization.
Key Features
โ
Edge-First Performance
Runs on Cloudflare Workersโ global network, generating images in <100ms.
โ
4 Visual Styles
Pre-built templates for different use cases:
- Modern gradients
- Eco/tech themes
- Branded designs (e.g., Cloudflare)
- GitHub-style profile cards
โ
Font Loading Flexibility
Choose your strategy without licensing headaches:
// Example: Load Google Fonts
const font = await googleFont(text, 'Noto Sans JP', 900, 'normal');
// Or self-host fonts via GitHub
const font = await githubFonts();
โ
Automatic Caching
Reduce compute costs by caching fonts and generated images:
// Enable cache middleware
og.get('/og', ...middleware.cache());
โ
Tailwind CSS Integration
Style cards with familiar utility classes for rapid iteration.
How It Works
- Send a GET request with parameters:
/og?mainText=Hello World&description=Edge-Powered OG Magic&style=1
- Get a 1200x630px social-ready image optimized for Twitter, LinkedIn, etc.
Quickstart Guide
- Clone the repo:
git clone https://github.com/mohdlatif/og-image-generator-cloudflare-worker
- Install dependencies (uses Bun ๐):
bun install
- Deploy to Cloudflare:
bun run deploy
For a detailed walkthrough, check out my Cloudflare Workers tutorial.
Why This Matters
- Cost-effective: No need for dedicated image servers
- Scalable: Workers handle spikes effortlessly
- Customizable: Add your own styles/fonts in minutes
๐ GitHub Repo
mohdlatif/og-image-generator-cloudflare-worker
If you find this useful:
- โญ Star the repo to help others discover it
- ๐ฌ Share feedback โ Iโd love to hear your use cases!
- ๐ ๏ธ Contribute: PRs welcome for new styles, optimizations, or docs!
Letโs make dynamic OG images a solved problem for everyone! ๐
P.S. Big thanks to the Hono and Vercel OG teams for their amazing tools!
Top comments (0)