Suggest an editImprove this articleRefine the answer for “What is `generateStaticParams`?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`generateStaticParams` in **Next.js (App Router)** is a server function that tells Next.js which values of a dynamic route's parameters need to be generated in advance at build time. **Key point:** it turns a dynamic route into a set of static pages (SSG).Shown above the full answer for quick recall.Answer (EN)Image`generateStaticParams` in **Next.js (App Router)** is a **server function** that tells Next.js **which values of a dynamic route's parameters need to be generated in advance at build time**. Simply put: > **It turns a dynamic route into a set of static pages (SSG).** --- ## Why `generateStaticParams` is needed Without it, a dynamic route: ```txt app/blog/[slug]/page.tsx ``` - does not know **which** `slug` values **exist**. `generateStaticParams`: - returns a list of `slug` values - Next.js generates HTML **for each value** - pages are served from the CDN as regular static files --- ## Basic example ```ts export async function generateStaticParams() { const posts = await getPosts() return posts.map(post => ({ slug: post.slug, })) } ``` ```ts export default function Page({ params }) { return <Article slug={params.slug} /> } ``` Result: `/blog/post-1`, `/blog/post-2`, `/blog/post-3` - **static pages** --- ## Where it is used blogs documentation catalogs SEO pages roadmaps --- ## Connection with rendering | Scenario | Behavior | |---|---| | `generateStaticParams` exists | SSG | | + `revalidate` | ISR | | No `generateStaticParams` | SSR (on request) | --- ## Important nuances ### 1. Runs **only on the server** - database access - API access - secrets are safe --- ### 2. Works **only with the App Router** it doesn't exist in `pages/` only `app/` --- ### 3. Can be combined with ISR ```ts export const revalidate = 60 ``` - pages update without a rebuild --- ### 4. Doesn't have to cover everything You can: - generate **popular pages** - render the rest on request --- ## Frequent mistakes confusing it with `getStaticPaths` (Pages Router) returning the wrong object shape expecting client-side access --- ## Short interview answer > `generateStaticParams` **is an App Router function in Next.js that defines the list of dynamic route parameters for static page generation at build time.**For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.