Add dynamic social card images to your Express routes with a single URL construction.
Start IntegratingUse Node.js's built-in URL class. No external libraries required.
Works with EJS, Pug, Handlebars, or any other template engine.
Share your OG URL generation logic across routes using middleware.
// routes/blog.js
const express = require('express');
const router = express.Router();
router.get('/blog/:slug', async (req, res) => {
const post = await Post.findOne({ slug: req.params.slug });
if (!post) return res.status(404).send('Not found');
const ogUrl = new URL('https://imagoapi.com/api/og/generate');
ogUrl.searchParams.set('title', post.title);
ogUrl.searchParams.set('template', 'modern');
ogUrl.searchParams.set('api_key', process.env.IMAGO_API_KEY);
res.render('post', { post, ogUrl: ogUrl.toString() });
});
// In EJS: <meta property="og:image" content="<%= ogUrl %>">
Start using Imago API today and add beautiful social cards to your Express app.
Try Imago API Free