Next.js
Functions
Complete reference for all generate-metadata functions in Next.js
A simple guide to using generate-metadata functions in your Next.js application.
Quick Start
First, create a metadata client:
getMetadata()
Generate AI-powered metadata for individual pages.
Basic Usage
Dynamic Pages
For pages with dynamic routes, include the dynamic parts in the path:
With Search Parameters
Include search parameters in the path for better caching:
getRootMetadata()
Generate metadata for layout components.
Simple Layout
Layout with Fallback
If you want default metadata when the API is unavailable:
Fallback Metadata
Use fallback metadata when the API is unavailable. It's optional but recommended:
Override Metadata
Use override
to force certain metadata values, regardless of what the API returns:
Complete Example
Here's a complete example showing all features:
Common Patterns
E-commerce Product Pages
Blog Posts
Category Pages
That's it! Your Next.js app now has AI-powered metadata generation.