Performance: Open Graph metadata
Open Graph metadata affects how social media platforms preview your page, impacting perceived load speed and user engagement but not the actual page rendering speed.
import Head from 'next/head'; export default function Page() { return ( <> <Head> <meta property="og:title" content="My Page" /> <meta property="og:description" content="Description here" /> <meta property="og:image" content="/optimized-image.jpg" /> <meta property="og:image:width" content="1200" /> <meta property="og:image:height" content="630" /> </Head> <main>Content</main> </> ); }
import Head from 'next/head'; export default function Page() { return ( <> <Head> <meta property="og:title" content="My Page" /> <meta property="og:description" content="Description here" /> <meta property="og:image" content="/large-image.jpg" /> <meta property="og:image:width" content="4000" /> <meta property="og:image:height" content="3000" /> </Head> <main>Content</main> </> ); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large og:image with high resolution | 0 (metadata only) | 0 | 0 | [X] Bad |
| Optimized og:image with proper size | 0 (metadata only) | 0 | 0 | [OK] Good |
metadata export to automatically add Open Graph tags for sharing previews.metadata as an object.openGraph property within metadata.export const metadata = {
openGraph: {
title: 'Welcome',
description: 'Home page',
url: 'https://example.com',
images: ['https://example.com/image.png']
}
}og:title content in the rendered HTML?title inside openGraph sets the og:title tag content.og:title will be 'Welcome'.export const metadata = {
openGraph: {
title: 'Page',
images: 'https://example.com/img.png'
}
}images as an array of URLs, not a single string.imageUrl. Which approach correctly sets the metadata in a Next.js App Router page?generateMetadata function that receives page props.generateMetadata returning metadata using params.imageUrl.Pass the test and this pattern moves unknown