Performance: GenerateStaticParams for static paths
MEDIUM IMPACT
This affects the build time and initial page load speed by pre-generating static pages for known paths.
export async function generateStaticParams() { const res = await fetch('https://api.example.com/popular-items'); const data = await res.json(); return data.map(item => ({ id: item.id.toString() })); } // Only generates static pages for popular items, reducing build time and bundle size.
export async function generateStaticParams() { const res = await fetch('https://api.example.com/all-items'); const data = await res.json(); return data.map(item => ({ id: item.id.toString() })); } // This fetches all items including rarely visited ones, generating thousands of pages.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Generate all paths statically | N/A (build time cost) | N/A | N/A | [X] Bad for large datasets |
| Generate only popular paths statically | N/A | N/A | N/A | [OK] Good balance |
| No static generation, fully dynamic | N/A | N/A | N/A | [!] OK but slower initial load |