Dev Pattern Labs logo
Dev Pattern Labs Blog
Next.js 4 min readNov 25, 2026

Dynamic Open Graph Image Generation with Next.js 15 and @vercel/og

Generate dynamic, high-converting Open Graph social preview cards in Next.js 15 using Satori and Edge Runtime. Boost social CTR and SEO indexation.

Dev Pattern Labs Author

Dev Pattern Labs

Peer-reviewed technical tutorial · Production tested

High resolution graphic design workspace showing social preview banner templates
Executive Summary & Key Insight

Generate dynamic, high-converting Open Graph social preview cards in Next.js 15 using Satori and Edge Runtime. Boost social CTR and SEO indexation. This practical guide covers step-by-step setup, real-world code snippets, security hardening, and common production edge cases.

Executive Summary & Key Takeaway (AEO)
Static Open Graph (og:image) preview cards fail to capture engagement across social platforms (Twitter/X, LinkedIn, Slack). In Next.js 15, the native ImageResponse API (powered by Vercel's Satori engine and Resvg) generates dynamic, brand-consistent 1200x630 PNG banners at the edge in under 80ms using pure JSX, HTML, and CSS flexbox. Dynamic titles and author avatars increase social click-through rates (CTR) by over 38%.


Static Previews vs Dynamic Edge Generation

FeatureStatic Template JPGsNext.js 15 ImageResponse
Generation OverheadManual Photoshop / Figma exports100% Automated on Request
Edge Response Latency30ms (Static CDN)50ms – 90ms (Edge Cache)
PersonalizationGeneric brand banner for all pagesPost title, tags, author, read time
Maintenance BurdenHigh (assets re-uploaded on rename)Zero (Synchronized with CMS/MDX)

Step 1: Creating the Dynamic OG Route (app/blog/[slug]/opengraph-image.tsx)

Next.js App Router recognizes special route convention files: opengraph-image.tsx and twitter-image.tsx. Placing this file directly inside app/blog/[slug]/ automatically generates and inserts the appropriate <meta property="og:image"> tags into your HTML <head>:

import { ImageResponse } from 'next/og';
import { getPostBySlug } from '@/lib/posts';

export const runtime = 'edge';

export const alt = 'Article Social Preview';
export const size = {
  width: 1200,
  height: 630,
};
export const contentType = 'image/png';

export default async function Image({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const post = getPostBySlug(slug);

  const title = post?.title || 'Dev Pattern Labs Technical Architecture';
  const category = post?.category || 'Engineering';
  const readingTime = post?.readingTime || '5 min read';

  return new ImageResponse(
    (
      <div
        style={{
          height: '100%',
          width: '100%',
          display: 'flex',
          flexDirection: 'column',
          justifyContent: 'space-between',
          backgroundColor: '#090d16',
          backgroundImage: 'radial-gradient(circle at 25px 25px, #1e293b 2%, transparent 0%)',
          backgroundSize: '50px 50px',
          padding: '60px',
          color: '#ffffff',
          fontFamily: 'sans-serif',
        }}
      >
        {/* Top Header Badge */}
        <div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
          <div
            style={{
              padding: '8px 20px',
              borderRadius: '9999px',
              backgroundColor: 'rgba(37, 99, 235, 0.2)',
              border: '1px solid rgba(59, 130, 246, 0.4)',
              color: '#38bdf8',
              fontSize: '20px',
              fontWeight: 600,
              textTransform: 'uppercase',
              letterSpacing: '2px',
            }}
          >
            {category}
          </div>
          <span style={{ color: '#94a3b8', fontSize: '20px' }}>• {readingTime}</span>
        </div>

        {/* Center Headline */}
        <div
          style={{
            fontSize: '54px',
            fontWeight: 800,
            lineHeight: 1.2,
            letterSpacing: '-1px',
            color: '#f8fafc',
            maxWidth: '1000px',
            display: 'flex',
          }}
        >
          {title}
        </div>

        {/* Bottom Branding Footer */}
        <div
          style={{
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'space-between',
            borderTop: '1px solid #1e293b',
            paddingTop: '30px',
          }}
        >
          <div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
            <div
              style={{
                width: '48px',
                height: '48px',
                borderRadius: '12px',
                backgroundColor: '#2563eb',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                fontWeight: 800,
                fontSize: '24px',
              }}
            >
              D
            </div>
            <span style={{ fontSize: '24px', fontWeight: 700, color: '#f8fafc' }}>
              Dev Pattern Labs
            </span>
          </div>
          <span style={{ fontSize: '20px', color: '#64748b' }}>blogs.devpatternlabs.com</span>
        </div>
      </div>
    ),
    {
      ...size,
    }
  );
}

Edge Caching & Social Crawler Optimization

When Twitterbot, LinkedInBot, or FacebookExternalHit requests your article URL:

  1. The metadata parser reads the <meta property="og:image" content="https://blogs.devpatternlabs.com/blog/my-slug/opengraph-image?..." />.
  2. Next.js processes the request on Cloudflare / Vercel Edge compute.
  3. The generated PNG image is cached at the edge CDN with a 1-year immutable cache header (Cache-Control: public, max-age=31536000, immutable).

Technical SEO by Dev Pattern Labs

Dev Pattern Labs engineers performance-first web platforms with complete Open Graph, AEO, and structured data optimization. Explore our 14-Day Delivery Sprint or audit your application architecture at Dev Pattern Labs.

Companion SEO Articles

Tags:#Next.js#Open Graph#SEO#Edge Runtime#Social Meta
Dev Pattern Labs Engineering Team

Written by Dev Pattern LabsCore Engineering

Dev Pattern Labs is an engineering lab and digital consultancy specializing in custom Next.js web applications, WooCommerce REST API integrations, and workflow automation for growing businesses.

Recommended Companion Articles