Skip to main content
userTourKit
@tour-kit/adoptionHooks

useAdoptionContext

Low-level hook returning the raw AdoptionProvider context — features, usage map, nudge state, and full action surface

domidex01Published Updated

Low-level access to the raw AdoptionContext value. Most consumers should use useFeature or useNudgeuseAdoptionContext is the escape hatch when you need everything at once (custom dashboards, debugging, headless integrations).

useAdoptionContext throws if no <AdoptionProvider> is mounted above.

Usage

import { useAdoptionContext } from '@tour-kit/adoption';

function FeatureMatrix() {
  const { features, usageMap, pendingNudges } = useAdoptionContext();
  return (
    <table>
      {features.map((f) => (
        <tr key={f.id}>
          <td>{f.name}</td>
          <td>{usageMap[f.id]?.count ?? 0}</td>
          <td>{pendingNudges.includes(f) ? 'Pending nudge' : 'OK'}</td>
        </tr>
      ))}
    </table>
  );
}

Return Value

FieldTypeDescription
featuresFeature[]All registered features
usageMapRecord<string, FeatureUsage>Per-feature usage records
nudgeStateNudgeStateNudge persistence state (snoozed, dismissed, last shown)
pendingNudgesFeature[]Features whose nudge is currently due
trackUsage(featureId: string) => voidManually record a feature usage event
getFeature(featureId: string) => FeatureWithUsage | nullResolve a feature + its usage
showNudge(featureId: string) => voidForce-show a nudge
dismissNudge(featureId: string) => voidPersist a dismissal
snoozeNudge(featureId: string, durationMs: number) => voidHide for a duration

For typical adoption flows, prefer useFeature (single feature) or useNudge (single nudge). They wrap useAdoptionContext with narrower APIs.

On this page