Vue Tour
Vue Tour is a lightweight, simple, and customizable plugin designed to guide users through applications built with Vue.js. It allows developers to create interactive, step-by-step tours by targeting specific DOM elements. The current stable version is 2.0.0, which was released recently and includes a significant update to Popper.js v2.x for positioning. While not on a strict release cadence, the project shows active development with features like sticky steps, promise-based `before` hooks for async operations, and element highlighting introduced in previous minor versions. Its primary differentiator is its simplicity and direct integration with Vue's reactivity system, making it a straightforward choice for adding onboarding or feature discovery flows without heavy dependencies, utilizing standard CSS selectors for targeting tour steps.
Common errors
-
TypeError: Cannot read properties of undefined (reading 'start') OR TypeError: this.$tours[tourName] is undefined
cause The tour component (`<v-tour>`) was not rendered, or its `name` prop does not match the key used to call `this.$tours[tourName].start()`.fixVerify that `<v-tour name="myTour" :steps="steps"></v-tour>` is present in your template and that the `name` prop (e.g., 'myTour') exactly matches the string used to access it via `this.$tours['myTour']`. -
Popper: `modifiers.popperOffsets.offset` (or similar property) is not a valid Popper.js v2 option.
cause This error occurs after upgrading to vue-tour v2.0.0 if you are still passing Popper.js v1.x options in your step `params`.fixConsult the Popper.js v2.x documentation for the correct syntax and available options. Update the `params` object for each step to conform to the new Popper.js API. -
Error: [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup
cause This can occur when using SSR (Server-Side Rendering) if Vue Tour's DOM manipulations or dynamic elements cause a mismatch between the server-rendered and client-side hydrated content.fixConsider dynamically importing or rendering `<v-tour>` only on the client-side using a `<client-only>` wrapper in Nuxt.js or a similar mechanism in other SSR frameworks, or ensure all tour-related elements are fully mounted before hydration.
Warnings
- breaking Vue Tour v2.0.0 updated its internal Popper.js dependency to v2.x. Any custom Popper.js options passed via step parameters must be updated to align with Popper.js v2.x API changes.
- gotcha Tour steps rely on `target` selectors (e.g., `#id`, `.class`, `[data-v-step]`) to find DOM elements. If a targeted element is not present in the DOM when a step attempts to show, the tour step will not appear or may throw an error.
- gotcha The `before` function within a tour step expects a Promise to be returned. If the promise is rejected, the tour will not proceed to that step. Forgetting to return a Promise or returning a non-Promise value can lead to unexpected behavior.
- gotcha If you are using a bundler (e.g., Webpack, Rollup) and experience issues with Vue Tour's styles not applying, it's often due to the CSS import not being processed correctly or style isolation issues in your Vue components.
Install
-
npm install vue-tour -
yarn add vue-tour -
pnpm add vue-tour
Imports
- VueTour
import { VueTour } from 'vue-tour';import VueTour from 'vue-tour';
- CSS Stylesheet
require('vue-tour/dist/vue-tour.css'); // While technically works in some setups, 'import' is idiomatic for modern Vue CLI/Vite projects.import 'vue-tour/dist/vue-tour.css';
- Vue.use()
new Vue({ VueTour }); // Incorrect plugin registration.Vue.use(VueTour);
Quickstart
import Vue from 'vue';
import App from './App.vue';
import VueTour from 'vue-tour';
import 'vue-tour/dist/vue-tour.css';
Vue.use(VueTour);
Vue.config.productionTip = false;
new Vue({
render: h => h(App)
}).$mount('#app');