i18
i18nexus Library
Complete React i18n toolkit with cookie-based language management and SSR support
๐ฆInstallation
npm install i18nexusOr using yarn: yarn add i18nexus
Key Features
๐จ
I18nProvider
React Context Provider with cookie-based language persistence
Learn More โ
๐ค
useTranslation
Hook to access translation function in Client Components
Learn More โ
๐
useLanguageSwitcher
Language change hook with cookie persistence
Learn More โ
๐ฅ๏ธ
Server Components
Server-side translations with zero hydration mismatches
Learn More โ
๐Quick Start
1. I18nProvider Setup
// app/layout.tsx
import { I18nProvider } from "i18nexus";
import { translations } from "@/lib/i18n";
export default function RootLayout({ children }) {
return (
<I18nProvider initialLanguage="ko" translations={translations}>
{children}
</I18nProvider>
);
}2. Use in Components
"use client";
import { useTranslation, useLanguageSwitcher } from "i18nexus";
export default function MyComponent() {
const { t } = useTranslation();
const { currentLanguage, changeLanguage } = useLanguageSwitcher();
return (
<div>
<h1>{t("Welcome")}</h1>
<button onClick={() => changeLanguage("en")}>
English
</button>
</div>
);
}