Dynamic social previews for every page
Generate beautiful og:image previews automatically. Screenshot templates or live pages. Perfect for blogs, e-commerce, and SaaS.
import { Stack0 } from '@stack0/sdk'const stack0 = new Stack0({ apiKey: process.env.STACK0_API_KEY })// Generate og:image for a blog postexport async function generateOGImage(post: BlogPost) {const ogUrl = new URL('https://yoursite.com/og-template')ogUrl.searchParams.set('title', post.title)ogUrl.searchParams.set('author', post.author)ogUrl.searchParams.set('date', post.date)const { imageUrl } = await stack0.screenshots.captureAndWait({url: ogUrl.toString(),width: 1200,height: 630, // Standard og:image sizeformat: 'webp',deviceScaleFactor: 2, // Retina quality})return imageUrl}// Or capture existing page as og:imageexport async function capturePageAsOG(pageUrl: string) {const { imageUrl } = await stack0.screenshots.captureAndWait({url: pageUrl,width: 1200,height: 630,format: 'webp',selector: '#og-hero', // Capture specific element})return imageUrl}
Features
What's included
Custom Templates
Design HTML templates with your brand. Pass dynamic data via URL parameters.
Element Selection
Capture a specific element instead of the full page. Perfect for hero sections.
Fast Generation
Sub-3-second capture time. Generate images on-demand without slow builds.
Global CDN
Generated images served from edge locations worldwide for fast loading.
Batch Processing
Generate images for hundreds of pages at once. Perfect for migration or updates.
Response Caching
Cache by URL or custom key. Avoid regenerating images for unchanged content.
Why Stack0
Built for production
Standard dimensions
Generate 1200x630 images optimized for Twitter, Facebook, LinkedIn, and other platforms.
Retina quality
Use 2x device scale factor for crisp images on high-density displays.
Dynamic content
Pass title, author, date, or any data through URL parameters to your template.
WebP format
Modern format with excellent compression. Smaller files, faster social sharing.
CDN delivery
Images served from our global CDN. Fast loading worldwide.
Response caching
Cache generated images to avoid redundant captures. Same input, same output.
Applications
Common implementations
Blog Posts
Generate unique preview images for each article with title, author, and date.
Product Pages
Show product images, prices, and ratings in social previews.
User Profiles
Create personalized social cards with user avatars and stats.
Event Pages
Display event details, dates, and speakers in shareable preview images.
FAQ
Frequently asked questions
The recommended size is 1200x630 pixels, which works well across Twitter, Facebook, LinkedIn, and other platforms. Use deviceScaleFactor: 2 for retina-quality images.
Create an HTML page that reads URL parameters (title, author, image, etc.) and renders them. Then call our API with those parameters in the URL. Your template handles the design, we capture the screenshot.
Yes. Include any web fonts in your HTML template using @font-face or Google Fonts. Our rendering engine supports all modern web fonts.
Screenshots typically generate in 2-3 seconds. Use response caching to avoid regenerating images for unchanged content. Cached images are served instantly from our CDN.
Yes. Call our API during your build process to pre-generate og:images for all pages. For dynamic content, generate on-demand and cache. Both approaches work well.
Ready to build?
Plans start at $5/month.