Next.js Discord

Discord Forum

Nextjs 13.5.1 missing exported function "generateStaticParams()"

Answered
TT posted this in #help-forum
Open in Discord
Avatar
TTOP
Hi all!
I am working on a project which targetted to be build as a static website by using output: "export" in next.config.js.
Today I trying to upgrade the version from nextjs@13.4.19 to nextjs@13.5.1.
But it raised a new error when I run next dev.
Error: Page "/[lng]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config.


While page "/[lng]/page" is exporting a static method with some route segment config
export const dynamic = 'force-static'
export const dynamicParams = false;
export async function generateStaticParams() {
  return languages.map((lng) => ({ lng }))
}


I found it quite strange, because the project can be next build && next export as a static website
Route (app)                              Size     First Load JS
┌ ○ /                                    387 B          79.9 kB
├ ○ /_not-found                          878 B          80.4 kB
├ ● /[lng]                               111 kB          286 kB
├   ├ /en
...


After some investigation, I've found a [PR](https://github.com/vercel/next.js/pull/54351) which cause this error happen. Is it a bug for next dev or I've did something wrong in the code?

*edit: formatting
Answered by West African Lion
On further experimentation, I'm not actually sure that this is a bug as much as it throwing imprecise errors.

Everything works correctly as long as you don't use output: 'export' and dynamic/dynamicParams together.

If you take either of those out, everything works as expected:

* Without the output option, it will properly serve 404s when visiting a route that isn't generated.
* With or without the route segment config, next build will export a valid configuration by generating HTML pages for each output of generateStaticParams.

The errors only actually happen in next dev when both of the aforementioned conditions are present.

This scenario probably just warrants updated documentation and maybe extra sanity checks.

GitHub issue: https://github.com/vercel/next.js/issues/56253
View full answer

5 Replies

Avatar
West African Lion
Did you ever find a solution? I am encountering this same issue right now.

my /[[...slug]]/page is exporting a generateStaticParams function, but I'm getting the error about saying it's missing.

Using Next 13.5.3
Avatar
joulev & fuma pray for Schneider
This is a nextjs bug I think. You should
* open an issue on github if there isn’t one on this matter already
* use maybe 13.4.19 for now
Avatar
West African Lion
I was just digging through Github and didn't see any issues. I'll give it a shot on 13.4.19 and Canary before opening one.

Thanks!
Avatar
West African Lion
Confirmed the issue still exists in Canary, so I'm going to open an issue.

Falling back to 13.4.19 makes the error go away, but it also causes export const dynamic = 'error' and export const dynamicParams = false to be ignored, so I'm not sure what the behavior will be during an actual static export.
Avatar
West African Lion
On further experimentation, I'm not actually sure that this is a bug as much as it throwing imprecise errors.

Everything works correctly as long as you don't use output: 'export' and dynamic/dynamicParams together.

If you take either of those out, everything works as expected:

* Without the output option, it will properly serve 404s when visiting a route that isn't generated.
* With or without the route segment config, next build will export a valid configuration by generating HTML pages for each output of generateStaticParams.

The errors only actually happen in next dev when both of the aforementioned conditions are present.

This scenario probably just warrants updated documentation and maybe extra sanity checks.

GitHub issue: https://github.com/vercel/next.js/issues/56253
Answer