react-i18next documentation
🏠 i18next🌐 localization as a service🎓 i18next crash course💾 GitHub Repository
  • Introduction
  • Getting started
  • Guides
    • Drawbacks of other i18n solutions
    • Quick start
    • Multiple Translation Files
    • Extracting translations
  • latest
    • Step by step guide
    • i18next instance
    • useTranslation (hook)
    • withTranslation (HOC)
    • Translation (render prop)
    • Trans Component
    • I18nextProvider
    • SSR (additional components)
    • Migrating v9 to v10
    • TypeScript
  • Misc
    • Using with ICU format
    • Using with fluent format
    • Testing
  • legacy v9
    • Step by step guide (v9)
    • Overview (v9)
    • i18next instance (v9)
    • I18nextProvider (v9)
    • withI18n (v9)
    • withNamespaces (v9)
    • NamespacesConsumer (v9)
    • Trans Component (v9)
    • Interpolate (v9)
    • SSR (v9)
  • 🌐localization as a service
  • 🎓i18next crash course
  • 💾GitHub Repository
Powered by GitBook
On this page
  • Using Next.js App Router?
  • Using Next.js?
  • Using Remix?
  • Using Gatsby?
  • Setting the i18next instance based on req
  • Passing initial translations / initial language down to client
  • using the useSSR hook
  • using the withSSR HOC
  1. latest

SSR (additional components)

Last updated 1 month ago

Using App Router?

Then check out describing how to best internationalize it with i18next.

Using ?

You should have a look at which extends react-i18next to bring it to next.js the easiest way.

With next-i18next@v8.0.0 and Next.js v10, next-i18next has done a major rewrite of the package, leveraging the built-in provided by Next.js.

you can also find a next-i18next app example in combination with locize, that offers 2 different approaches.

next-i18next@v5.0.0 supports Next.js v9.5 in (as of ). If your goal is to use earlier versions of Next.js with Serverless, then you should have a look at , which is a Next.js 9 boilerplate with built-in i18next, react-i18next and Locize.

Looking for an optimized Next.js translations setup? you'll find a blog post on how to best use next-i18next with client side translation download and SEO optimization.


Using SSG / next export? you'll find a simple tutorial on how to best use next-i18next in a SSG environment.

Using ?

You should have a look at which extends react-i18next to bring it to Remix the easiest way.

you'll find a simple example and on how to best use remix-i18next.

Setting the i18next instance based on req

<I18nextProvider i18n={req.i18n}>
  <App />
</I18nextProvider>

Passing initial translations / initial language down to client

To avoid asynchronous loading of translation on the client side (and the possible Suspense out of that) you will need to pass down initialLanguage (will call changeLanguage on i18next) and initialI18nStore (will prefill translations in i18next store).

using the useSSR hook

import React from 'react';
import { useSSR } from 'react-i18next';

export function InitSSR({ initialI18nStore, initialLanguage }) {
  useSSR(initialI18nStore, initialLanguage);

  return <App />
}

using the withSSR HOC

import React from 'react';
import { withSSR } from 'react-i18next';
import App from './App';

const ExtendedApp = withSSR()(App);

<ExtendedApp initialLanguage={} initialI18nStore={} />

The ExtendedApp in this case will also have the composed ExtendedApp.getInitialProps()

Using ?

You should have a look at which extends react-i18next to bring it to Gatsby the easiest way.

you'll find a simple example and on how to best use .

Use the to inject the i18next instance for example bound to the http i18n instance on the request object using .

Gatsby
gatsby-plugin-react-i18next
Here
here a step by step tutorial
gatsby-plugin-react-i18next
I18nextProvider
i18next-http-middleware
Next.js
this article
Next.js
next-i18next
internationalized routing
Here
Serverless mode
July 2020
"Next Right Now"
Here
Here
Remix
remix-i18next
Here
here a step by step tutorial