Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPR: A required root parameter (locale) was not provided in generateStaticParams for /[locale] #1618

Open
3 tasks done
DiPSoMaNiE opened this issue Dec 18, 2024 · 3 comments
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@DiPSoMaNiE
Copy link

DiPSoMaNiE commented Dec 18, 2024

Description

Starting from [email protected] with experimental ppr enabled and use of setRequestLocale, I get the following error:

Error: A required root parameter (locale) was not provided in generateStaticParams for /[locale], please provide at least one value.

This error happened while generating the page. Any console logs will be displayed in the terminal window.
validateParams
node_modules/next/src/build/static-paths/app.ts (187:15)
validateParams
node_modules/next/src/build/static-paths/app.ts (512:7)

The error also occurs on [email protected] and [email protected] but everything works fine on [email protected].

Not knowing if it's a next-intl or a next issue, I'm reporting this in case it is an upcoming breaking change from next.

Verifications

Mandatory reproduction URL

https://github.com/DiPSoMaNiE/next-intl-bug-repro-app-router

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Run bun run dev (or install / run dev with another package manager)
  3. Visit http://localhost:3000 and see error

Expected behaviour

Should not get any error.

@DiPSoMaNiE DiPSoMaNiE added bug Something isn't working unconfirmed Needs triage. labels Dec 18, 2024
@amannn
Copy link
Owner

amannn commented Dec 18, 2024

Thanks for the report! I think that's related to the upcoming rootParams API, which should make setRequestLocale obsolete. I've got an experimental PR open here that explores these upcoming features: #1531. It's still a bit early with these APIs, I'm currently investigating how these can be adopted. I hopefully have more to share on this soon!

Have you tried adding generateStaticParams as mentioned in the error message?

@masterjanic
Copy link

Thanks for the report! I think that's related to the upcoming rootParams API, which should make setRequestLocale obsolete. I've got an experimental PR open here that explores these upcoming features: #1531. It's still a bit early with these APIs, I'm currently investigating how these can be adopted. I hopefully have more to share on this soon!

Have you tried adding generateStaticParams as mentioned in the error message?

I am experiencing the same issue on 15.1.1-canary.20, but I am not using setRequestLocale and I am using:

export function generateStaticParams() {
  return routing.locales.map((locale) => ({ locale }));
}

I have a nested layout like [locale]/some-path/[slug]. When trying to define generateStaticParams for the dynamic slug segment I get this error, but only if I have an empty array returned.

Should still be working IMO, so I guess it is a next bug. Let me know what you think!

@gijsbotje
Copy link

I ran into the same issue when trying PPR on my new project. Turns out I missed the static rendering section: https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering
It explains adding the generateStaticParams and setRequestLocale that are necessary to get it working. After adding those, it works fine. @amannn hopefully the rootParams API will be released soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

4 participants