Tours · Practical
Save progress and resume onboarding
Remember the current step across a reload, resume an unfinished tour and stop showing it after completion.
Try it live
Loading the interactive example…
Make it yours
Download HTMLimport { createTour, getPersistedProgress } from "sitetourkit";
import "sitetourkit/styles.css";
const PROGRESS = "sitetourkit:examples:resume-onboarding:progress:v1";
const COMPLETED = "sitetourkit:examples:resume-onboarding:completed:v1";
let tour;
const status = document.querySelector("#demo-status");
const saved = getPersistedProgress(PROGRESS, "local");
status.textContent =
saved === null
? "Ready to explore. Select Run example."
: `Progress saved at step ${saved + 1}. Run the example to resume.`;
document.querySelector("#run-demo").onclick = async () => {
tour?.destroy();
tour = createTour({
progress: true,
persistProgress: { key: PROGRESS, storage: "local" },
showOnce: { key: COMPLETED, storage: "local" },
steps: [
{
target: "#resume-workspace",
title: "Explore your workspace",
content: "Continue to step 2, then reload this demo to try resuming.",
},
{
target: "#resume-team",
title: "Meet your team",
content: "Reload the demo now. Run it again and you will resume here.",
},
{
target: "#resume-settings",
title: "Make it yours",
content: "Complete the tour to mark it as seen. Reset lets you try everything again.",
},
],
});
tour.on("stepChange", ({ index }) => {
status.textContent = `Progress saved at step ${index + 1} of 3.`;
});
tour.on("complete", () => {
status.textContent = "Completed and remembered. Reset to try again.";
});
const started = await tour.start();
if (!started)
status.textContent = "You already completed this tour. Reset to try it again.";
};
document.querySelector("#reset-demo").onclick = () => {
tour?.destroy();
localStorage.removeItem(PROGRESS);
localStorage.removeItem(COMPLETED);
status.textContent = "Saved state cleared for this example only.";
};
// Destroying the instance releases its UI without discarding saved progress.
window.addEventListener("pagehide", () => tour?.destroy());
Pick up where the visitor left off
Run the tour and move to step 2. Select Reload demo above the frame, then Run example again. The tour resumes at the saved step. Finish with Done, reload and run again: the completion flag prevents another automatic walkthrough.
Reset removes the two keys used by this example, allowing a fresh run. It leaves other application state untouched.
Combine progress and completion
persistProgress stores the current step. getPersistedProgress() lets the host show a useful resume message before starting. showOnce records completion so an already finished tour can stay out of the way.
This example uses local storage to survive a reload. Choose session storage if the progress should expire with the browser session.
Distinguish navigation from an explicit exit
A reload or navigation preserves unfinished progress. Explicitly exiting the tour clears its progress key. The example's page cleanup calls destroy() to release the UI while retaining the progress needed by the next load.
Use separate, versioned keys for progress and completion. Clear only those keys when offering a restart action.