When using last versions for next-i18next, react-18next and i18next, the setup instructions don't work. On the server, translations are not loaded, resulting in a hydratation error: Error: Text content does not match server-rendered HTML..
This (very simple) home page and the basic configuration mentioned in the setup instructions causes the error :
On the server, the console.log prints "false home.title". In the browser I can see the translated text ("Static page"), with the hydratation error.
To Reproduce
A reproduction repo can be found here : https://github.com/Alarid/i18next-repro
I created the project using npx create-next-app@latest --typescript --eslint i18next-repro, then I added the dependencies using yarn add next-i18next react-i18next i18next.
Expected behavior
Translations should be loaded on the server, when building static and server-side pages.
This wasn't the error I was trying to showcase when I created the reproduction repo. In fact, I have another project with exactly the same packages versions where translations are being successfully loaded on the server, and everything work as expected when pages use getStaticProps.
However, when switching the page to getServerSideProps, they seem to only be ready in the page file. All the components used in the page (and written in other files, located in src/components don't have access to the translations (ready = false), causing the same hydratation error. This was the error I was trying to get help on, but I spent two hours trying to reproduce it, and I couldn't. No idea what's going on here.
š Bug Report
When using last versions for next-i18next, react-18next and i18next, the setup instructions don't work. On the server, translations are not loaded, resulting in a hydratation error:
Error: Text content does not match server-rendered HTML.
.This (very simple) home page and the basic configuration mentioned in the setup instructions causes the error :
On the server, the console.log prints "false home.title". In the browser I can see the translated text ("Static page"), with the hydratation error.
To Reproduce
A reproduction repo can be found here : https://github.com/Alarid/i18next-repro I created the project using
npx create-next-app@latest --typescript --eslint i18next-repro
, then I added the dependencies usingyarn add next-i18next react-i18next i18next
.Expected behavior
Translations should be loaded on the server, when building static and server-side pages.
Your Environment
Relevant packages versions:
Side note
This wasn't the error I was trying to showcase when I created the reproduction repo. In fact, I have another project with exactly the same packages versions where translations are being successfully loaded on the server, and everything work as expected when pages use
getStaticProps
.However, when switching the page to
getServerSideProps
, they seem to only be ready in the page file. All the components used in the page (and written in other files, located insrc/components
don't have access to the translations (ready
= false), causing the same hydratation error. This was the error I was trying to get help on, but I spent two hours trying to reproduce it, and I couldn't. No idea what's going on here.