TourKit
API Reference

@tour-kit/adoption API

API reference for @tour-kit/adoption: AdoptionProvider, useFeature, useNudge, useAdoptionStats, and dashboard exports

@tour-kit/adoption API Reference

Complete API reference for the adoption package. This package provides feature adoption tracking with automatic nudging.


Providers

AdoptionProvider

Provider for feature adoption tracking.

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

<AdoptionProvider
  features={features}
  storage={{ type: 'localStorage', key: 'adoption' }}
  nudge={{ enabled: true, cooldownMs: 86400000, maxPerSession: 3 }}
  userId="user-123"
  onAdoption={(feature) => console.log('Adopted:', feature.name)}
  onChurn={(feature) => console.log('Churned:', feature.name)}
>
  {children}
</AdoptionProvider>
PropTypeDescription
featuresFeature[]Array of feature definitions
storageStorageConfigStorage configuration
nudgeNudgeConfigNudge configuration
userIdstringUser identifier for multi-user support
onAdoption(feature: Feature) => voidCalled when feature is adopted
onChurn(feature: Feature) => voidCalled when feature adoption is lost
onNudge(feature: Feature, action: string) => voidCalled on nudge interaction

Hooks

useFeature

Hook for tracking single feature adoption.

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

const {
  feature,
  usage,
  isAdopted,
  status,
  useCount,
  trackUsage,
} = useFeature('feature-id');
ReturnTypeDescription
featureFeature | undefinedFeature configuration
usageFeatureUsage | undefinedUsage tracking data
isAdoptedbooleanWhether feature is adopted
statusAdoptionStatusCurrent adoption status
useCountnumberNumber of times feature was used
trackUsage() => voidManually track a usage

useAdoptionStats

Hook for aggregate adoption statistics.

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

const {
  totalFeatures,
  adoptedCount,
  adoptionRate,
  byCategory,
  byStatus,
} = useAdoptionStats();
ReturnTypeDescription
totalFeaturesnumberTotal number of features
adoptedCountnumberNumber of adopted features
adoptionRatenumberAdoption rate (0-100)
byCategoryRecord<string, CategoryStats>Stats grouped by category
byStatusRecord<AdoptionStatus, number>Counts by status

useNudge

Hook for controlling nudge queue.

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

const {
  currentNudge,
  queue,
  show,
  dismiss,
  skip,
} = useNudge();
ReturnTypeDescription
currentNudgeFeature | nullCurrently shown nudge
queueFeature[]Queued nudges
show(featureId: string) => voidShow nudge for feature
dismiss() => voidDismiss current nudge
skip() => voidSkip current nudge

useAdoptionAnalytics

Hook for analytics integration.

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

const analytics = useAdoptionAnalytics();

Components

AdoptionNudge

Auto-shows nudges for unadopted features.

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

<AdoptionNudge
  position="bottom-right"
  delay={2000}
  size="default"
  render={({ feature, dismiss }) => <CustomNudge />}
/>
PropTypeDescription
positionstringPosition of nudge
delaynumberDelay before showing (ms)
size'sm' | 'default' | 'lg'Size variant
render(props) => ReactNodeCustom render function
asChildbooleanMerge props to child element

FeatureButton

Button with automatic usage tracking.

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

<FeatureButton
  featureId="feature-export"
  onClick={handleExport}
  variant="default"
>
  Export
</FeatureButton>
PropTypeDescription
featureIdstringFeature to track
onClick() => voidClick handler
variantstringButton variant

IfNotAdopted / IfAdopted

Conditional rendering based on adoption status.

import { IfNotAdopted, IfAdopted } from '@tour-kit/adoption';

<IfNotAdopted featureId="feature-search">
  <NewFeatureBadge>New!</NewFeatureBadge>
</IfNotAdopted>

<IfAdopted featureId="feature-search">
  <span>Power user!</span>
</IfAdopted>

NewFeatureBadge

Badge component for new features.

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

<NewFeatureBadge variant="default" size="sm">
  New
</NewFeatureBadge>

Dashboard Components

AdoptionDashboard

Full admin dashboard for adoption metrics.

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

<AdoptionDashboard features={features} />

AdoptionStatsGrid

Grid of stat cards.

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

<AdoptionStatsGrid />

AdoptionTable

Sortable, filterable table of features.

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

<AdoptionTable
  sortable
  filterable
  onRowClick={(feature) => {}}
/>

AdoptionCategoryChart

Chart showing adoption by category.

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

<AdoptionCategoryChart type="bar" />

Types

Feature

interface Feature {
  id: string;
  name: string;
  trigger: string | { event: string } | (() => void);
  adoptionCriteria?: AdoptionCriteria;
  resources?: FeatureResources;
  priority?: number;
  category?: string;
  description?: string;
  premium?: boolean;
}

AdoptionCriteria

interface AdoptionCriteria {
  minUses?: number;
  recencyDays?: number;
  custom?: (usage: FeatureUsage) => boolean;
}

AdoptionStatus

type AdoptionStatus = 'not_started' | 'exploring' | 'adopted' | 'churned';

FeatureUsage

interface FeatureUsage {
  featureId: string;
  useCount: number;
  firstUsedAt: Date | null;
  lastUsedAt: Date | null;
  adoptedAt: Date | null;
}

On this page