Deviopath › Next.js

generateStaticParams

Easy · Static Generation

For a dynamic route like app/blog/[slug]/page.tsx, you can export generateStaticParams() to tell Next.js which pages to build ahead of time (at build time). It returns an array of params objects, one per page: [{ slug: "hello" }, { slug: "news" }].

Write generateStaticParams(posts) that returns { slug } for every **published** post, in the same order.

Simplified: the real function takes no arguments and fetches the posts itself; here the posts are passed in.

Next: Health Check Endpoint