Repository navigation
How to use next-18next with cache components enabled (Next.js 16.4)? #2353
|
I would love to see an example project where next-18next is used with
Thanks in advance. |
Replies: 1 comment 5 replies
|
Hi @rkrisztian, thanks for the detailed questions. I reproduced your setup with Next.js 16.4.3, 1. Is For clean URLs plus prerendered routes, yes. With 2. The error on I see two possible causes:
The "pass // app/[lng]/layout.tsx is the root layout (no app/layout.tsx above it)
import { initServerI18next, getT, getResources, generateI18nStaticParams } from 'next-i18next/server'
import { I18nProvider } from 'next-i18next/client'
import i18nConfig from '../../i18n.config'
initServerI18next(i18nConfig)
export function generateStaticParams() {
return generateI18nStaticParams()
}
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const { i18n, lng } = await getT()
// with preload: [] only ship the current and the fallback language
const resources = getResources(i18n, undefined, [lng, 'en'])
return (
<html lang={lng}>
<body>
<I18nProvider language={lng} resources={resources}>
{children}
</I18nProvider>
</body>
</html>
)
}3. They work together. The layout above ran with both. If the error is still there after moving the layout and turning off |
The fix is on master now (228eed2): the server instance inits with
initAsync: falseby default, so the option is no longer needed.Do you need a release right away, or is it fine for you if I wait a couple of days and bundle it with other changes? Until then,
i18nextOptions: { initAsync: false }in your config does the same.