Skip to Content
🎉 Nextra 4.0 is released. dimaMachina is looking for a new job or consulting .
APIgenerateStaticParamsFor

generateStaticParamsFor Function

Generates static parameters based on your content directory structure.

This helper function is designed to work with Next.js’ generateStaticParams function to create static paths for all your MDX/Markdown pages.

Exported from nextra/pages.

Signature

Parameters:
NameTypeDefault
segmentKeystring

The name of your catch-all route segment (e.g., 'slug', 'mdxPath').

localeSegmentKeystring

The name of the locale segment when you have i18n.

"lang"
Returns:
() => Promise<{ [x: string]: string | string[]; }[]>

A function that generates an array of parameters for static page generation.

Example

Basic usage with a catch-all route

// app/[[...slug]]/page.tsx export const generateStaticParams = generateStaticParamsFor('slug')

Usage with i18n support

// app/[locale]/[[...mdxPath]]/page.tsx export const generateStaticParams = generateStaticParamsFor('mdxPath', 'locale')