Skip to main content
The Metadata APIs define your application’s <head> tags for SEO, social sharing, and browser behavior. Next.js automatically generates the relevant HTML from the metadata you export.
The metadata export and generateMetadata function are only supported in Server Components (layouts and pages).

Default fields

Two <meta> tags are always added by Next.js, even when no metadata is defined:

Static metadata

Export a metadata object from a layout.tsx or page.tsx file:

Dynamic metadata

Use generateMetadata to fetch metadata that depends on route parameters or external data:

Avoiding duplicate data fetches

When the same data is needed in both generateMetadata and the page component, use React’s cache to deduplicate the request:

Metadata fields

The Metadata object supports the following commonly used fields:
string | object
The page title. Can be a plain string, or an object with default, template, and absolute for title inheritance across layouts.
string
Page description used by search engines.
string | string[]
Keywords for the page.
object[]
Page authors.
object
Canonical and alternate URLs.
Used by social platforms (Facebook, LinkedIn, Slack) to generate link previews.
Controls how your page appears when shared on X (formerly Twitter).
Instructs search engine crawlers.
Define favicons and Apple touch icons.

File-based metadata

Next.js supports special file conventions that generate metadata automatically: Place these files in the app directory (or in a route segment folder for route-specific metadata).

Generated Open Graph images

Use the ImageResponse constructor from next/og to generate dynamic OG images using JSX:
ImageResponse supports flexbox and a subset of CSS properties. Advanced layouts using display: grid are not supported. Test your OG images at the Vercel OG Playground.

Streaming metadata

For dynamically rendered pages, Next.js streams metadata separately from page content, injecting it into <head> once generateMetadata resolves. This means visual content can start streaming before metadata is ready. Streaming metadata is disabled for known bots and crawlers (e.g. Twitterbot, Bingbot) that expect metadata to be in the initial HTML. You can customize this behavior with the htmlLimitedBots config option.