I18nextProvider (v9)
The provider is responsible to pass the i18next instance passed in by props down to all the withNamespaces hocs or NamespacesConsumer render prop using react context api.
1
import React from 'react';
2
import ReactDOM from 'react-dom';
3
import { I18nextProvider } from 'react-i18next';
4
5
import App from './App'; // your entry page
6
import i18n from './i18n'; // initialized i18next instance
7
8
ReactDOM.render(
9
<I18nextProvider i18n={ i18n }>
10
<App />
11
</I18nextProvider>,
12
document.getElementById('app')
13
);
Copied!
For the i18n instance have a look at the i18next instance page.
As an alternative you can use the reactI18nextModule in the i18n instance.

The I18nextProvider props:

name
type (default)
description
i18n
object (undefined)
pass i18next instance the provider will pass it down to translation components by context
defaultNS
string (undefined)
optionally pass down a default namespace to your translate HOC, I18n render prop (without having to specify it there)
initialI18nStore
object (undefined)
pass in initial translations (useful for serverside rendering)
initialLanguage
string (undefined)
pass in initial language (useful for serverside rendering)
Last modified 3yr ago