Socket
Book a DemoInstallSign in
Socket

@djangocfg/og-image

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@djangocfg/og-image

Dynamic Open Graph image generation for Next.js with customizable templates, social media previews, and SEO optimization

latest
Source
npmnpm
Version
1.4.30
Version published
Maintainers
1
Created
Source

@djangocfg/og-image

Dynamic Open Graph image generation for Next.js with customizable templates, social media previews, and SEO optimization

npm version License: MIT

Part of DjangoCFG — a modern Django framework for building production-ready SaaS applications. All @djangocfg/* packages are designed to work together, providing type-safe configuration, real-time features, and beautiful admin interfaces out of the box.

Overview

@djangocfg/og-image simplifies Open Graph image generation for Next.js applications. Create beautiful, dynamic social media preview images that boost click-through rates on Twitter, Facebook, LinkedIn, and other platforms.

Features

  • Dynamic Generation - Generate OG images on-the-fly
  • Edge Runtime - Fast, global deployment with Vercel Edge
  • Customizable Templates - Pre-built and custom templates
  • Google Fonts - Load fonts dynamically without bundling
  • Base64 Safe URLs - Avoid encoding issues
  • TypeScript - Full type safety

Installation

npm install @djangocfg/og-image
# or
pnpm add @djangocfg/og-image
# or
yarn add @djangocfg/og-image

Quick Start

API Route Handler

// app/api/og/route.tsx
import { ImageResponse } from 'next/og';
import { loadGoogleFonts } from '@djangocfg/og-image/utils';

export const runtime = 'edge';

export default async function handler(req) {
  const fonts = await loadGoogleFonts([
    { family: 'Manrope', weight: 700 }
  ]);

  return new ImageResponse(
    <YourTemplate />,
    { width: 1200, height: 630, fonts }
  );
}

Generate OG Image URLs

import { generateOgImageUrl } from '@djangocfg/og-image/utils';

// Base64 encoding (safe, default)
const url = generateOgImageUrl('/api/og', {
  title: 'Page Title',
  subtitle: 'Description'
});

Use in SEO Meta Tags

<meta property="og:image" content={ogImageUrl} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />

Exports

PathDescription
@djangocfg/og-imageMain exports
@djangocfg/og-image/handlerRequest handlers
@djangocfg/og-image/componentsPre-built templates
@djangocfg/og-image/utilsUtility functions

API Reference

loadGoogleFonts(fonts)

Load fonts from Google Fonts API.

const fonts = await loadGoogleFonts([
  { family: 'Manrope', weight: 700 },
  { family: 'Inter', weight: 400 }
]);

generateOgImageUrl(baseUrl, params, useBase64?)

Generate OG image URL with params.

const url = generateOgImageUrl('/api/og', {
  title: 'Hello',
  description: 'World'
}, true); // base64 encoding (default)

Image Dimensions

PlatformRecommended Size
Facebook1200 x 630
Twitter1200 x 600
LinkedIn1200 x 627
Discord1200 x 630

Requirements

  • Next.js >= 13.0.0
  • React >= 18.0.0

Documentation

Full documentation available at djangocfg.com

Contributing

Issues and pull requests are welcome at GitHub

License

MIT - see LICENSE for details

Keywords

og-image

FAQs

Package last updated on 29 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts