بنقرة واحدة
react
React and Expo integration guide for Better Translate providers, hooks, and typed translation access.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
React and Expo integration guide for Better Translate providers, hooks, and typed translation access.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Extract source strings, generate locale files, and remove unused keys for Better Translate projects.
Expo and React Native integration guide using Better Translate React support.
Package map and reading order for Better Translate product skills.
Guide for combining Better Translate packages without duplicating translation ownership.
Smallest Better Translate setup for plain TypeScript, Node.js, Bun, APIs, and shared libraries.
Map of Better Translate example apps to copy from when starting a new integration.
استنادا إلى تصنيف SOC المهني
| name | react |
| description | React and Expo integration guide for Better Translate providers, hooks, and typed translation access. |
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.