Generate rich link previews like Slack, Discord, and Twitter. Show users what they'll find before they click.
When building a chat app, social platform, or content management system, you want to show rich previews when users share links. The traditional approach relies on Open Graph (OG) meta tags, but:
Smaller sites, web apps, and internal tools often lack meta tags entirely.
The preview might show old content while the actual page has changed.
Some images are too small, wrong aspect ratio, or low quality.
Instead of relying on OG tags, capture a real screenshot of the website. This guarantees:
Works for any URL, even without meta tags configured.
The preview shows the current state of the page.
Same dimensions and quality for every preview.
// Express.js endpoint
app.get('/api/link-preview', async (req, res) => {
const { url } = req.query;
// Optimal dimensions for social cards
const params = new URLSearchParams({
url: url,
api_key: process.env.SNAPAPI_KEY,
width: '1200',
height: '630',
response: 'binary'
});
const response = await fetch(
`https://snapapi.alterra-solutions.com/v1/screenshot?${params}`
);
// Cache for 24 hours
res.set('Cache-Control', 'public, max-age=86400');
res.set('Content-Type', 'image/png');
res.send(Buffer.from(await response.arrayBuffer()));
});
<!-- In your chat message or card component -->
<div class="link-preview">
<img
src="/api/link-preview?url=https://github.com"
alt="Link preview"
loading="lazy"
/>
<div class="link-info">
<h4>GitHub</h4>
<p>github.com</p>
</div>
</div>
Under 2 seconds for most URLs. Perfect for real-time chat apps.
Cache responses at your CDN layer for instant repeat requests.
1200×630 dimensions perfect for Twitter, LinkedIn, Facebook.
Start free, scale as you grow. Predictable pricing.
Start with 100 free screenshots per month. No credit card required.
Get Free API Key →