Skip to main content
userTourKit
@tour-kit/reactHooks

useTourRegistryContext

Low-level hooks for reading the registered tour list inside MultiTourKitProvider. Use useTours for ergonomic access.

domidex01Published

Low-level access to the tour registry exposed by MultiTourKitProvider. Most consumers should use useToursuseTourRegistryContext is the escape hatch for custom registry integrations (declarative <Tour> mounting, tour deduplication, debug panels).

Usage

import { useTourRegistryContext } from '@tour-kit/react';

function RegistrySize() {
  const { tours } = useTourRegistryContext();
  return <span>Registered tours: {tours.length}</span>;
}

useTourRegistryContext throws if no <MultiTourKitProvider> is mounted above. Use useTourRegistryContextOptional if rendering inside a tree that may or may not have a provider.

Return Value

FieldTypeDescription
toursTour[]All currently registered tours.
registerTour(tour: Tour) => voidAdd a tour to the registry. Called internally by <Tour> on mount.
unregisterTour(tourId: string) => voidRemove a tour from the registry. Called internally by <Tour> on unmount.

useTourRegistryContextOptional

Same as useTourRegistryContext but returns null instead of throwing when no provider is present. Useful for components that may render outside a MultiTourKitProvider.

import { useTourRegistryContextOptional } from '@tour-kit/react';

function ContextAwareLauncher() {
  const ctx = useTourRegistryContextOptional();
  if (!ctx) return <button>Help</button>; // standalone mode
  return <TourSelector tours={ctx.tours} />;
}

Returns TourRegistryContextValue | null.

For tour listing, completion checks, and active-tour state, prefer useTours — it wraps useTourRegistryContext and exposes a flatter API (tours, activeTourId, isTourCompleted, etc.).

Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.

MIT-licensed — no signup, no credit card. Pay once, only when you ship.