Internationalization, static rendering and cookies() #70723
-
|
I'm working on a multi-language e-commerce app and somehow I can't manage to access the session ID stored in an HTTP-only cookie from a server component without having to make all routes for the entire application dynamic. The problem here is that I'm using static route generation for the root layout, as described in the docs: export async function generateStaticParams() {
return [{ lang: 'en-US' }, { lang: 'de' }]
}
export default function Root({ children, params }) {
return (
<html lang={params.lang}>
<body>{children}</body>
</html>
)
}If I understand correctly, I can't force a single page under the root layout (so in this case, every page) to be dynamic, so I can't access cookies from the server. Or I have to abandon static rendering for the entire app, which is just insane. I'm really hoping I'm missing something here. Any advice would be greatly appreciated. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Could you have multiple root layouts, as a way to opt in certain pages into dynamic behavior? https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts |
Beta Was this translation helpful? Give feedback.
Could you have multiple root layouts, as a way to opt in certain pages into dynamic behavior? https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts