QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.19k stars 52 forks source link

Could not find locale while pre-rendering page #342

Open vitorGabr opened 5 months ago

vitorGabr commented 5 months ago

A build error when building vercel with the experimental PPR: true

build: Error: Could not find locale while pre-rendering page, make sure you called setStaticParamsLocale at the top of your pages

QuiiBz commented 5 months ago

Could you share a minimal reproduction? You can use the CodeSandbox template: https://codesandbox.io/p/devbox/jovial-paper-skkprk

matheusgrieger commented 5 months ago

Saw this issue as well. Happened to me when trying to set the lang attribute on the html tag for the root layout (app/layout.tsx, not inside app/[locale]/layout.tsx). I used getCurrentLocale and so it was triggering errors when building.

Tried to do this because Next was overriding the lang attribute when rendering the app afterwards, as their docs mention that it is required to have a root layout, but I don't have the current locale available to set that attribute.

Works fine in development though.

dBianchii commented 1 month ago

Happening to me as well. I have my home page like this:

image

And my layout.tsx like this: image