Skip to main content
userTourKit
@tour-kit/coreHooks

useResolveLocalizedText

Returns a memoized (value) => string resolver. Use for consumer-authored copy that must be a string — aria-label, title, Dialog.Title.

domidex01Published

String-only sibling of useResolvedText. Returns a memoized resolver:

function useResolveLocalizedText(): (value: LocalizedText | undefined) => string

Use it whenever the surface you're handing copy to requires a string (not a ReactNode) — aria-label, title attributes, Dialog.Title text, document.title updates, etc.

Usage

import { useResolveLocalizedText } from '@tour-kit/core';

function TaskRow({ task }: { task: ChecklistTaskConfig }) {
  const resolveText = useResolveLocalizedText();
  return (
    <li aria-label={resolveText(task.title)}>
      {/* ... */}
    </li>
  );
}

Resolution rules

InputResult
undefined / null''
stringinterpolate(value, userContext, { warnOnMissing: false })
{ key }useT()(value.key, userContext)
any other ReactNode'' (JSX cannot render to a string)

vars are sourced from useSegmentationContext().userContext — the same shape that drives audience targeting. Without a <SegmentationProvider>, userContext is undefined and templates fall back to {{x | default}} rules.

For ReactNode outputs (tour body copy, hint titles), use useResolvedText — it accepts JSX and returns ReactNode. This hook is the narrower variant for string-only sinks.

Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.

MIT-licensed — no signup, no credit card. Pay once, only when you ship.