
2025-08-22 — By Akshay Singh · 9 min read
If you’ve ever built a React app and thought “How will users from other countries use this?” then localisation is your answer. Adding internationalisation (i18n) ensures your app feels native to users in any region — whether they speak English, Hindi, Spanish, or Arabic. In this guide, I’ll walk you through setting up localisation in React using react-i18next, a library I’ve personally found reliable in real-world projects.
When I first added Hindi translations to a React project, I noticed how much smoother the user experience became. Users actually stayed longer just because the UI felt familiar.
We’ll use react-i18next and i18next.
npm install i18next react-i18next i18next-http-backend i18next-browser-languagedetector
Inside public/locales create folders per language:
public/locales/
en/translation.json
hi/translation.json
Example English (en/translation.json):
{
"nav": { "home": "Home", "about": "About", "contact": "Contact" },
"hero": {
"title": "Build faster with React",
"subtitle": "Ship international-ready apps"
},
"footer": { "copyright": "© {{year}} My Company" }
}
Example Hindi (hi/translation.json):
{
"nav": { "home": "घर", "about": "हमारे बारे में", "contact": "संपर्क" },
"hero": {
"title": "React के साथ तेज़ बनाएं",
"subtitle": "अंतरराष्ट्रीय-तैयार ऐप्स लॉन्च करें"
},
"footer": { "copyright": "© {{year}} मेरी कंपनी" }
}
Create src/i18n.js:
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import HttpBackend from "i18next-http-backend";
import LanguageDetector from "i18next-browser-languagedetector";
i18n
.use(HttpBackend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",
supportedLngs: ["en", "hi"],
interpolation: { escapeValue: false },
backend: { loadPath: "/locales/{{lng}}/{{ns}}.json" },
react: { useSuspense: true },
});
export default i18n;
Import ./i18n in your index.js / main.jsx before rendering <App />.
import { useTranslation } from "react-i18next";
function Header() {
const { t } = useTranslation();
return (
<nav>
<a>{t("nav.home")}</a>
<a>{t("nav.about")}</a>
<a>{t("nav.contact")}</a>
</nav>
);
}
Dynamic values:
const year = new Date().getFullYear()
<p>{t('footer.copyright', { year })}</p>
import { useTranslation } from "react-i18next";
function LangSwitcher() {
const { i18n } = useTranslation();
return (
<select
value={i18n.language}
onChange={(e) => i18n.changeLanguage(e.target.value)}
>
<option value="en">English</option>
<option value="hi">हिन्दी</option>
</select>
);
}
Persist the choice with localStorage for a better user experience.
{
"notifications": "You have {{count}} notification",
"notifications_plural": "You have {{count}} notifications"
}
<p>{t("notifications", { count: items.length })}</p>
<html dir="rtl">.fallbackLng → app may break if user’s language isn’t supported.home.title vs title.home).t().hreflang tags for multilingual SEO if using SSR.useTranslation in unit tests.Localising React apps isn’t complicated once you set it up correctly. It not only helps you reach new audiences but also makes your app feel polished and professional.
Have you tried localisation in your React projects yet? Share your thoughts or issues in the comments — I’d love to hear how you approached it!