Singleton with i18Next
Unanswered
Purple Martin posted this in #help-forum

Purple MartinOP
in the documentation for i18next with app router, we can see the following piece of code:
Why do we have to create a new instance on every render ? Could we just create a singleton ?
async function initI18next(lng: string, ns: string) {
// on server side we create a new instance for each render, because during compilation everything seems to be executed in parallel
const i18nInstance = createInstance();
await i18nInstance
.use(initReactI18next)
.use(
resourcesToBackend(
(language: string, namespace: string) =>
import(`./locales/${language}/${namespace}.json`),
),
)
.init(getOptions(lng, ns));
return i18nInstance;
}
Why do we have to create a new instance on every render ? Could we just create a singleton ?