Next.js · Middle · Question 11 of 75
What does generateStaticParams do?
- ✓Correct answer: Returns segment values to prerender at build time
- 2Generates random route parameters for A/B tests
- 3Creates query parameters for all
<Link>s on the page
Explanation
export function generateStaticParams() { return posts.map(p => ({ slug: p.slug })) } - these pages are built ahead of time. It replaces getStaticPaths from the Pages Router. With Cache Components, the function must return at least one set of params - that's how the build verifies the route doesn't access request data incorrectly.