Next.js · Middle · Question 11 of 75

What does generateStaticParams do?

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.

Further reading

Problem with a question

Next.js · Middle · question 11

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz