skills/react/SKILL.md
React and Expo integration guide for Better Translate providers, hooks, and typed translation access.
npx skillsauth add jralvarenga/better-translate reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this guide when React components need translations and locale switching.
@better-translate/core@better-translate/react@better-translate/coreBetterTranslateProvideruseTranslations()import { BetterTranslateProvider } from "@better-translate/react";
import { translator } from "./i18n";
export function Root() {
return (
<BetterTranslateProvider translator={translator}>
<App />
</BetterTranslateProvider>
);
}
The simplest no-extra-generic setup is to bind the translator once and export an app-local provider + hook pair.
createBetterTranslateReact(translator)import { createBetterTranslateReact } from "@better-translate/react";
import { translator } from "./i18n";
export const { BetterTranslateProvider, useTranslations } =
createBetterTranslateReact(translator);
Then import your app-local useTranslations instead of importing the package hook directly:
import { useTranslations } from "./i18n";
export function Header() {
const { t } = useTranslations();
return <h1>{t("home.title")}</h1>;
}
These fallback patterns are still supported too.
import { useTranslations } from "@better-translate/react";
import { translator } from "./i18n";
export function Header() {
const { locale, setLocale, t } = useTranslations<typeof translator>();
return (
<>
<h1>{t("home.title")}</h1>
<button onClick={() => setLocale("es")} disabled={locale === "es"}>
Espanol
</button>
</>
);
}
useTranslations()Create src/better-translate.d.ts:
import { translator } from "./i18n";
declare module "@better-translate/react" {
interface BetterTranslateReactTypes {
translator: typeof translator;
}
}
Then components can use the hook without a generic and still keep autocomplete:
import { useTranslations } from "@better-translate/react";
export function Header() {
const { t } = useTranslations();
return <h1>{t("home.title")}</h1>;
}
React by itself is enough for:
If the app is Next.js App Router, keep @better-translate/react for client hooks and add @better-translate/nextjs for routing and server helpers.
documentation
Repository map for finding Better Translate packages, docs, and examples.
tools
Snapshot of the current public Better Translate package and adapter surface.
documentation
Right-to-left locale configuration guide for Better Translate.
tools
Next.js App Router setup guide for Better Translate routing, server helpers, and optional React hooks.