Browse docs

API

Stift instance

ReactVanilla

What the instance does after construction, grouped by concern. Translating has its own page; everything stateful lives here.

Locale

  • getLocale(): RegisteredLocale — the active locale, narrowed to your registered union.
  • getDirection(): 'ltr' | 'rtl' — derive dir attributes from this, never the tag.
  • setLocale(locale): void — reactive switch, persists the preference to state.
  • subscribe(fn): () => void — store subscription; the returned function unsubscribes.
  • detectLocale(ctx?): Promise<RegisteredLocale> — runs detection.order ('persisted' reads the stored preference).

Boot and packs

  • initialize({ locale?, critical? }): Promise<void> — swaps to the target locale and loads per loadingStrategy; resolves once the critical namespaces are ready.
  • installLocale(locale, namespaces?): Promise<boolean> / activateLocale(locale): Promise<boolean> / isLocaleInstalled(locale): Promise<boolean> — the offline install lifecycle.
  • getPackSize(locale): Promise<PackSizeInfo> — byte-accurate download accounting.
  • pack: PackManager — staleness checks and refresh; the offline guide owns the detail.

Params and units

  • setParam(name, value): void — typed override against the declared values, persisted unless persist: false. resetParam(name) / resetAllParams() drop overrides.
  • setUnit(category, unit): void — typed override, validated and persisted. resetUnit(category) / resetAllUnits() drop overrides.
  • getUnits(): Partial<Record<UnitCategory, string>> — the effective per-category record. getUnitValues(category) lists the allowed values for a picker.

Examples

// Backend-driven personalization: push the value in, it persists locally.
await stift.setLocale(user.locale)
stift.setParam('gender', user.gender)

Next