Skip to main content
userTourKit
@tour-kit/coreTypes

Tour Types

TypeScript interfaces for TourState, TourActions, TourCallbacks, and the complete tour lifecycle type system

domidex01Published

TourConfig

interface TourConfig {
  id: string;
  steps: TourStep[];
  autoStart?: boolean;
  startAt?: number;
  keyboard?: KeyboardConfig | boolean;
  spotlight?: SpotlightConfig | boolean;
  persistence?: PersistenceConfig | boolean;
  a11y?: A11yConfig;
  scroll?: ScrollConfig;
  onStart?: (context: TourContext) => void;
  onComplete?: (context: TourContext) => void;
  onSkip?: (context: TourContext) => void;
  onStepChange?: (step: TourStep, index: number) => void;
}

TourState

interface TourState {
  tourId: string | null;
  isActive: boolean;
  currentStepIndex: number;
  currentStep: TourStep | null;
  totalSteps: number;
  isLoading: boolean;
  isTransitioning: boolean;
  completedTours: string[];
  skippedTours: string[];
}

TourContext

interface TourContext {
  tourId: string;
  currentStep: TourStep | null;
  currentStepIndex: number;
  totalSteps: number;
  isFirstStep: boolean;
  isLastStep: boolean;
}

Placement

type Side = 'top' | 'bottom' | 'left' | 'right';
type Alignment = 'start' | 'center' | 'end';
type Placement = Side | `${Side}-${Alignment}`;

// All valid placements:
// 'top' | 'top-start' | 'top-end'
// 'bottom' | 'bottom-start' | 'bottom-end'
// 'left' | 'left-start' | 'left-end'
// 'right' | 'right-start' | 'right-end'

TourCallbackContext

Argument passed to tour-level callbacks (onStart, onComplete, onSkip).

interface TourCallbackContext {
  tourId: string
  currentStepIndex: number
  totalSteps: number
  completedTours: string[]
  skippedTours: string[]
}

TourContextValue

Returned by useTourContext. Throw-on-missing variant; use useTourContextOptional to receive null instead.

interface TourContextValue {
  state: TourState
  actions: TourActions
  config: TourKitConfig
}

TourOptions

Per-tour overrides that mirror TourKitConfig (keyboard, spotlight, persistence, a11y, scroll). Used as the config prop on <Tour> and the options parameter on createTour().

type TourOptions = Omit<Tour, 'id' | 'steps'>

StepOptions

Per-step overrides used by createStep() and createNamedStep(). Mirrors the optional fields on TourStep.

type StepOptions = Omit<TourStep, 'id' | 'target' | 'content'>

Hints Types (re-exported)

Used by @tour-kit/hints; re-exported for consumers that need to type custom hint reducers.

interface HintsState {
  hints: Map<string, HintState>
  activeHint: string | null
}

type HintsActions =
  | { type: 'SHOW_HINT'; id: string }
  | { type: 'HIDE_HINT'; id: string }
  | { type: 'DISMISS_HINT'; id: string }
  | { type: 'RESET_HINT'; id: string }
  | { type: 'RESET_ALL' }

Hook Return Types

Hooks defined in @tour-kit/core document their return shape on each hook page; the type aliases below let you reference those shapes without inferring through the hook signature.

TypeReturned by
UseStepReturnuseStep
UseBranchReturnuseBranch
UseSpotlightReturnuseSpotlight
UseFocusTrapReturnuseFocusTrap
UseRoutePersistenceReturnuseRoutePersistence
UseAdvanceOnOptionsOptions for useAdvanceOn