You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a higher-level layout uses cookies and a nested dynamic route page ([locale]/test/[code]/page.tsx) with an empty generateStaticParams() is accessed, a DYNAMIC_SERVER_USAGE error occurs. Interestingly, accessing [locale]/page.tsx does not trigger this error.
Detailed Observations
Accessing cookies in the top-level layout (src/app/layout.tsx)
Scenario 1: Page with Empty generateStaticParams()
Error: DYNAMIC_SERVER_USAGE
Occurs when accessing src/app/[locale]/test/[code]/page.tsx
Scenario 2: Root Page
No error
Accessing src/[locale]/page.tsx works normally
Attempted Solutions
Returning a non-empty array in generateStaticParams()
Strangely even if I move cookies() to app/[locale]/layout.tsx. Not sure if there's a bug here in Next.js.
If I remove generateStaticParams in app/[locale]/layout.tsx, then the result looks more like what I'd expect:
This is somewhat related: vercel/next.js#64616. I hope that rootParams brings some improvements here, at least the case of a static layout + dynamic child is covered in the tests in the PR.
@amannn
During the build log, the page appears to be generated statically. However, when running pnpm build -d (to view detailed build logs), an error message is displayed: "Static generation failed due to dynamic usage on /en (and other pages too) , reason: cookies". By rendering new Date().toISOString() on the pages where static generation failed, we can confirm that the static build is indeed unsuccessful (the time changes with each page refresh and is not fixed). I expected this might be a Next.js issue and hope it can be resolved quickly. Thank you.
Description
When a higher-level layout uses cookies and a nested dynamic route page ([locale]/test/[code]/page.tsx) with an empty generateStaticParams() is accessed, a DYNAMIC_SERVER_USAGE error occurs. Interestingly, accessing [locale]/page.tsx does not trigger this error.
Detailed Observations
Accessing cookies in the top-level layout (
src/app/layout.tsx
)Scenario 1: Page with Empty generateStaticParams()
src/app/[locale]/test/[code]/page.tsx
Scenario 2: Root Page
src/[locale]/page.tsx
works normallyAttempted Solutions
Build Log Details
When running pnpm build -d, the build log shows:
Questions
Verifications
Mandatory reproduction URL
https://github.com/LoganBaek97/next-intl/tree/main/examples/example-app-router
Reproduction description
Steps to reproduce:
src/app/[locale]/test/[code]/page.tsx
,src/app/[locale].tsx
andsrc/app/layout.tsx (using cookies)
Expected behaviour
The text was updated successfully, but these errors were encountered: