createTour
createTour factory function: define type-safe tour configurations with validated steps, callbacks, and options
Factory function that creates a fully typed tour configuration.
Usage
import { createTour } from '@tour-kit/core';
const onboardingTour = createTour({
id: 'onboarding',
steps: [
{
id: 'welcome',
target: '#hero',
title: 'Welcome!',
content: 'Let us show you around.',
},
{
id: 'features',
target: '#features',
title: 'Features',
content: 'Check out our features.',
},
],
onComplete: () => {
console.log('Tour completed!');
},
});With Options
const tour = createTour({
id: 'feature-tour',
steps: [...],
autoStart: false,
startAt: 0,
keyboard: {
enabled: true,
bindings: {
next: ['ArrowRight', 'Enter'],
prev: ['ArrowLeft'],
},
},
spotlight: {
padding: 12,
borderRadius: 8,
},
persistence: {
strategy: 'localStorage',
key: 'feature-tour-state',
},
});Type Safety
The function provides full type inference:
const tour = createTour({
id: 'typed-tour',
steps: [
{
id: 'step-1',
target: '#btn',
// TypeScript will error on invalid properties
// @ts-expect-error
invalidProp: true,
},
],
});Return Type
Returns a TourConfig object that can be passed directly to TourProvider:
<TourProvider tour={onboardingTour}>
<App />
</TourProvider>Related
createStep— build the typedstepsarray this factory wraps.<TourProvider>— the provider that consumes the returnedTourConfig.useTour— drive the registered tour imperatively.- Tour types reference — every field the factory accepts.
- Schemas reference — JSON-safe alternative when tours come from a CMS.
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.
useSegmentationContext
Low-level hook returning the raw SegmentationContextValue — registered segments, userContext, and currentUserId. Use useSegment / useSegments for typical lookups.
createStep
createStep factory function: build type-safe step configurations with validation and IntelliSense autocomplete