Skip to content

Events

<Guide> exposes the tour lifecycle through callback props. Use them to persist progress, fire analytics, or coordinate with the rest of your app.

<Guide
tour={tour}
steps={steps}
isActive={isActive}
onNext={(stepId) => analytics.track("tour_step_advanced", { stepId })}
onStop={(stepId) => {
analytics.track("tour_completed", { lastStepId: stepId });
setIsActive(false);
}}
onDismiss={(stepId) => {
analytics.track("tour_dismissed", { stepId });
setIsActive(false);
}}
/>
PropSignatureFires when
onNext(stepId?: string) => voidThe user advances to the next step.
onStop(stepId?: string) => voidThe tour stops (either completed or explicitly stopped).
onDismiss(stepId?: string) => voidThe user closes the tour via the close button.

For fine-grained control, each step can carry its own onHighlightStarted, onHighlighted, and onDeselected hooks:

{
id: "step-save",
title: "Save your work",
onHighlighted: (element) => {
element?.classList.add("pulse");
},
onDeselected: (element) => {
element?.classList.remove("pulse");
},
configuration: { /* ... */ },
}

Guide.js is stateless by design. You control what gets persisted.

const [startIndex, setStartIndex] = useState(() => {
return Number(localStorage.getItem("tour.lastSeenStep") ?? 0);
});
<Guide
tour={tour}
steps={steps}
isActive
startIndex={startIndex}
onNext={(stepId) => {
const index = steps.findIndex((s) => s.id === stepId);
if (index >= 0) {
setStartIndex(index);
localStorage.setItem("tour.lastSeenStep", String(index));
}
}}
/>;