useResolveLocalizedText
Returns a memoized (value) => string resolver. Use for consumer-authored copy that must be a string — aria-label, title, Dialog.Title.
String-only sibling of useResolvedText. Returns a memoized resolver:
function useResolveLocalizedText(): (value: LocalizedText | undefined) => stringUse 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
| Input | Result |
|---|---|
undefined / null | '' |
string | interpolate(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.
Related
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.
useResolvedText
Resolve a LocalizedText | ReactNode value into a ReactNode. Handles string interpolation, i18n key lookup, and ReactNode pass-through with one call.
useSegmentationContext
Low-level hook returning the raw SegmentationContextValue — registered segments, userContext, and currentUserId. Use useSegment / useSegments for typical lookups.