Next.js Integration
Use Next.js built-innext/og for metadata image generation.
Installation
No additional packages needed -next/og is included with Next.js.
Setup
Define image metadata for pages:lib/source.ts
app/docs/[[...slug]]/page.tsx
Create Route Handler
Generate images at build time:app/og/docs/[...slug]/route.tsx
Customization
Customize the default image template:app/og/docs/[...slug]/route.tsx
CLI Templates
Install alternative templates using Fumadocs CLI:default- Default gradient templatemono- Monochrome templategradient- Custom gradient template
Takumi Integration
Takumi provides a framework-agnostic, high-performance alternative tonext/og.
Installation
Configure External Package
Add Takumi to external packages:next.config.ts
vite.config.ts
vite.config.ts
waku.config.ts
Next.js Usage
app/og/docs/[...slug]/route.tsx
React Router Usage
app/routes/og.docs.tsx
app/routes.ts
react-router.config.ts
Waku Usage
src/pages/_api/og/docs/[...slugs]/image.webp.tsx
Built-in Templates
Default Template
Properties
| Property | Type | Description |
|---|---|---|
title | ReactNode | Page title |
description | ReactNode | Page description |
site | ReactNode | Site name |
icon | ReactNode | Site icon/logo |
primaryColor | string | Background gradient color |
primaryTextColor | string | Text accent color |
Custom Templates
Create your own image template:lib/og-template.tsx
app/og/docs/[...slug]/route.tsx
Advanced Customization
Dynamic Content
Add dynamic elements to images:Custom Fonts
Load custom fonts:Images in Template
Embed images in your template:Best Practices
- Use recommended dimensions: 1200x630px is optimal for most platforms
- Keep text readable: Use large font sizes (48px+)
- High contrast: Ensure text is readable against background
- Test on multiple platforms: Preview on Twitter, Facebook, LinkedIn
- Optimize file size: Use WebP format with Takumi for smaller files
- Cache aggressively: Set
revalidate = falsefor static content - Handle missing data: Provide fallbacks for undefined values
- Use SVG for icons: Vector graphics scale better
Debugging
Verify Image Generation
Test your OG image route:Preview in Browser
Visit the image URL directly to see the generated image.Social Media Debuggers
Check Metadata
Verify Open Graph tags in your page:Performance
Takumi Benefits
- Faster generation: 2-3x faster than next/og
- Smaller file size: WebP format support
- Framework agnostic: Works with any framework
- Built-in fonts: Geist fonts pre-bundled