React reference
Ways
Root props
Common root props:
| Prop | Type | Notes |
|---|---|---|
apiKey | string | Required. |
locale | string | Current target locale. |
baseLocale | string | Source locale. |
persistLocaleCookie | boolean | Default locale-cookie policy for the root runtime. |
context | string | object | Optional root context. |
cacheTtl | number | Cache TTL for translation requests. |
messageFormatter | 'waysParser' | 'none' | fn | Parser or formatter override. |
fetcher | typeof fetch | Custom fetch implementation. |
acceptedLocales | string[] | Optional explicit locale list. |
Scoped props
Nested scopes accept:
| Prop | Type | Notes |
|---|---|---|
context | string | object | Required. |
locale | string | Optional locale override. |
baseLocale | string | Optional base locale override. |
components | Record<string, component> | Components used inside translatable content. |
T
T is the JSX-first translation primitive.
| Prop | Type | Notes |
|---|---|---|
children | ReactNode | Required. |
vars | Record<string, unknown> | Interpolation input. |
context | string | object | Optional leaf context override. |
components | Record<string, component> | Component mapping for rich content. |
fixed | boolean | Skip translation for fixed branding-like content. |
useT()
useT() returns a translation function for strings, attributes, and logic.
const t = useT();
const label = t('Save changes');Runtime hooks
useTranslatedMemo()
A memoized value that recomputes when translations change.
useTranslationLoading()
Returns true while the current context is still loading.
useCurrentLocale()
Reads the root runtime locale.
useSetCurrentLocale()
Returns the setter for the root runtime locale.
LanguageSwitcher
Common props:
| Prop | Type | Notes |
|---|---|---|
currentLocale | string | Controlled locale. |
onLocaleChange | (locale) => void | Change handler. |
direction | 'up' | 'down' | Menu direction. |
styles / classNames | object | Styling overrides. |
unstyled | boolean | Disable built-in styles. |
Utility exports
@18ways/react also re-exports:
fetchAcceptedLocalesfetchEnabledLanguagesresolveOrigin