Suggest an editImprove this articleRefine the answer for “What is dynamic metadata?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**Dynamic metadata** in Next.js is metadata that gets **computed at request time** and can depend on the route, data, the user, or external sources. **Key point:** it's SEO data that adapts to a specific page and its context.Shown above the full answer for quick recall.Answer (EN)Image**Dynamic metadata** in Next.js is metadata that gets **computed at request time** and can depend on the route, data, the user, or external sources. Put simply: > dynamic metadata is SEO data that adapts to a specific page and its context. --- ## How dynamic metadata is defined Dynamic metadata is described via the `generateMetadata` function: ```ts export async function generateMetadata({ params }) { return { title: `Post: ${params.slug}`, description: 'Article description' } } ``` Next.js calls this function **on the server** before rendering the page or layout. --- ## Where the data comes from Inside `generateMetadata` you can use: - `params` (dynamic route segments) - `searchParams` - `fetch` to an API or a database - request-level information This lets you build metadata based on the real content. --- ## Where dynamic metadata works Dynamic metadata can be used in: - `page.tsx` - `layout.tsx` - nested layouts - route groups Just like layouts, it's **inherited and overridden**. --- ## When dynamic metadata is needed Dynamic metadata is needed when: - the URL contains parameters (`/blog/[slug]`) - each page has unique content - SEO depends on the data - a CMS or an API is used - different Open Graph images are needed Examples: - a blog - product cards - user profiles - categories with different content --- ## An example with data loading ```ts export async function generateMetadata({ params }) { const post = await fetchPost(params.slug) return { title: post.title, description: post.excerpt, openGraph: { images: [post.cover] } } } ``` The metadata is built based on the real post data. --- ## Impact on performance Dynamic metadata: - runs on the server - can make requests - adds a small cost to rendering But: - it's cached the same way as `fetch` - it works correctly with ISR and SSR - it gives precise SEO --- ## Difference from static metadata | Static metadata | Dynamic metadata | |---|---| | A `metadata` object | A `generateMetadata` function | | Fixed data | Computed data | | Faster | A bit heavier | | No logic | You can write code | | For static pages | For dynamic routes | --- ### Summary Dynamic metadata is: - server-side metadata with logic - SEO tied to data - support for dynamic URLs - correct behavior with the App RouterFor the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.