Skip to content

`@palamedes/react`

@palamedes/react provides provider-free React runtime components, macro entry points, and headless locale-switch helpers.

@palamedes/react

Exports

  • Trans
  • Plural
  • Select
  • SelectOrdinal
  • buildLocaleSwitchItems(options)
  • Fragment
  • TransProps
  • PluralProps
  • SelectProps
  • SelectOrdinalProps
  • BuildLocaleSwitchItemsOptions
  • LocaleSwitchItem

Fragment is re-exported from React for generated/runtime component rendering paths that need the same import surface as other React helpers.

The locale-switch helper and related types are re-exported from @palamedes/core/locale.

The client subpath @palamedes/react/client exports:

  • useClientLocale(locale, sync)

The macro subpath @palamedes/react/macro exports compile-time macro components:

  • Trans
  • Plural
  • Select
  • SelectOrdinal

Runtime Components

Runtime components read the active i18n instance through @palamedes/runtime.

import { Trans } from "@palamedes/react"
;<Trans id="footer" message="Powered by <0>Palamedes</0>" components={{ 0: <strong /> }} />

For authoring source strings, prefer macro imports from @palamedes/react/macro so the build can extract and transform messages.

Locale Switch Helpers

import { buildLocaleSwitchItems } from "@palamedes/react"

const items = buildLocaleSwitchItems({
  currentLocale: "de",
  labels: { de: "Deutsch", en: "English" },
  locales: ["en", "de"],
})

useClientLocale(locale, sync) calls sync(locale) from a client component. The sync function may return a promise; the hook intentionally does not own loading UI or routing policy.