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

Low-level access to the raw AdoptionContext value. Most consumers should use useFeature or useNudge — useAdoptionContext 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.

Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is free while you build. Every package works unlicensed in development, a one-time licence from $9.99 removes the production watermark when you ship.

Free in development, no signup, no credit card. Pay once, only when you ship.

On this page