Replies: 1 comment
-
|
You’re right — what you’re seeing is the expected behavior of next-i18next, because serverSideTranslations() injects the translation resources into the page props to make them available for SSR and hydration. When you navigate client-side, Next.js reuses the JSON payload of the next page (including those translations), so you see that repeated 130KB block. There’s no built-in way to “skip” sending translations in the props and still have them available for SSR, because the server needs to serialize them for hydration consistency. That said, there are a few practical approaches to reduce this overhead: Namespace splitting: Use i18next-http-backend (or a custom backend): Cache translations client-side: In short: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm learning how next-i18next works. Currently we have a large-ish website, and all pages use the
serverSideTranslationslikeThat works fine, and will ensure that translations work on server side rendering with getServersideProps and getStaticProps.
On a full page load, this is obviously fine.
When the user does client-side navigation to a page that uses the same namespace, it seems wasteful to me to put the translations into the page props again-
Currently we have a single namespace at around 130KB, and splitting it into smaller chunks while ensuring that all the necessary translation strings are available correctly on all the pages is quite a task, especially since we have a lot of shared components between the pages.
What I'm wondering is, is there a way to prevent putting the translations into the props, but still support the server side rendering?
Beta Was this translation helpful? Give feedback.
All reactions