Performance: Metadata API (static metadata)
This affects the initial page load speed by providing metadata without runtime overhead.
export const metadata = { title: 'Static Page Title', description: 'Static description for SEO', };
export async function generateMetadata() { const res = await fetch('https://api.example.com/meta'); const data = await res.json(); return { title: data.title }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Runtime metadata fetch | No extra DOM nodes | 0 reflows | Blocks paint until data arrives | [X] Bad |
| Static metadata export | No extra DOM nodes | 0 reflows | No paint blocking, immediate metadata | [OK] Good |
metadata object in a Next.js page or layout?metadata object is used to add static information such as page title and description.metadata as an object.export const metadata = { title: 'Home' } correctly exports a constant object named metadata. The other options use incorrect export forms or syntax.export const metadata = { title: 'About Us', description: 'Learn about our team' }metadata object has a title set to 'About Us'.title property to set the browser tab's page title.export const metadata = { title: 'Contact', description: Contact us page }metadata export?url key.export const metadata = { title: 'Blog', description: 'Latest posts', openGraph: { images: [{ url: '/blog.png' }] } } correctly uses an array with an object containing url. The other options use incorrect formats.Pass the test and this pattern moves unknown