@tour-kit/adoptionHooks
useAdoptionContext
Low-level hook returning the raw AdoptionProvider context — features, usage map, nudge state, and full action surface
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
| Field | Type | Description |
|---|---|---|
features | Feature[] | All registered features |
usageMap | Record<string, FeatureUsage> | Per-feature usage records |
nudgeState | NudgeState | Nudge persistence state (snoozed, dismissed, last shown) |
pendingNudges | Feature[] | Features whose nudge is currently due |
trackUsage | (featureId: string) => void | Manually record a feature usage event |
getFeature | (featureId: string) => FeatureWithUsage | null | Resolve a feature + its usage |
showNudge | (featureId: string) => void | Force-show a nudge |
dismissNudge | (featureId: string) => void | Persist a dismissal |
snoozeNudge | (featureId: string, durationMs: number) => void | Hide for a duration |
For typical adoption flows, prefer useFeature (single feature) or useNudge (single nudge). They wrap useAdoptionContext with narrower APIs.