Next.js · Senior · Question 25 of 75
Why can't generateStaticParams return an empty array with Cache Components?
- ✓Correct answer: It needs sample params to validate the route at build time
- 2An empty array disables the route, and it always responds with 404
- 3The restriction applies only to
[...slug]routes
Explanation
The build renders the route with sample params and checks that cookies(), headers() and other request data sit inside Suspense. Without samples, validation is impossible, so it's a build error. You can return a placeholder and handle it with notFound(), but that weakens the check.