Skip to main content
userTourKit
@tour-kit/coreHooks

useTourKitContext

Hook returning the global TourKit context value — config, resolved direction, and global callbacks set on TourKitProvider

domidex01Published Updated

Returns the value provided by TourKitProvider: the resolved configuration, text direction, and global callbacks. Use this hook when a component needs to read the global config (e.g. spotlight padding, keyboard mappings) or react to global tour events.

useTourKitContext throws if no <TourKitProvider> is mounted above.

Usage

import { useTourKitContext } from '@tour-kit/core';

function SpotlightDebugger() {
  const { config, direction } = useTourKitContext();
  return (
    <pre>
      direction = {direction}
      spotlight padding = {config.spotlight?.padding}
    </pre>
  );
}

Return Value

FieldTypeDescription
configTourKitConfigResolved global configuration
direction'ltr' | 'rtl'Resolved text direction
isRTLbooleanConvenience flag, equivalent to direction === 'rtl'
onTourStart(tourId) => voidGlobal tour-start callback
onTourComplete(tourId) => voidGlobal tour-complete callback
onTourSkip(tourId, stepIndex) => voidGlobal tour-skip callback
onStepView(tourId, stepId, stepIndex) => voidGlobal step-view callback
onBranchAction(tourId, stepId, actionId, target) => voidBranch-action callback
onTourBranch(fromTourId, toTourId, fromStepId) => voidCross-tour branch callback

For just the direction, use useDirection — it's a thin wrapper that pulls only { direction, isRTL } from this context.

On this page