Performance: GenerateMetadata for dynamic metadata
MEDIUM IMPACT
This affects the page load speed by controlling when and how metadata is generated and sent to the browser, impacting the Largest Contentful Paint (LCP).
export async function generateMetadata() { return { title: 'Static or cached title' }; } // Fetch dynamic data on client or use ISR to update metadata periodically
export async function generateMetadata() { const res = await fetch('https://api.example.com/data'); const data = await res.json(); return { title: data.title }; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Dynamic metadata with live fetch | Minimal DOM impact | 0 reflows | Blocks initial paint until data arrives | [X] Bad |
| Static or cached metadata | Minimal DOM impact | 0 reflows | Non-blocking paint | [OK] Good |