vue3-smooth-scroll is a lightweight, actively maintained Vue 3 plugin dedicated to facilitating smooth scrolling experiences within web applications. It provides two primary methods for implementation: a declarative directive (`v-smooth-scroll`) that can be applied directly to anchor tags, and a more flexible programmatic API accessible through `this.$smoothScroll` in the Options API or `inject('smoothScroll')` within the Composition API. The plugin's design prioritizes Vue 3 compatibility, including robust Server-Side Rendering (SSR) support, which was recently improved in version 0.8.1 to address `window is not defined` errors. It uses `requestAnimationFrame` for efficient, non-blocking animations, with a graceful fallback for broader compatibility across different browser environments. Key features include Y-axis scrolling, the ability to define specific scroll containers, configurable animation duration, offset, and custom easing functions, providing a high degree of customization for scroll behavior. Its small bundle size (approximately 1.4kB gzipped) makes it a performant choice, offering significantly more advanced control and a programmatic interface compared to the native `scroll-behavior` CSS property, especially for intricate scrolling requirements or dynamic content. Releases appear to be driven by bug fixes and compatibility updates rather than a strict schedule, with 0.8.1 being the current stable version.
npm install vue3-smooth-scrollVerified import paths — ran on the pinned version, not inferred.
This example demonstrates both directive-based (`v-smooth-scroll`) and programmatic (`inject('smoothScroll')`) smooth scrolling, including usage with custom scroll containers and global/local options for duration and offset.
Upgrade to `vue3-smooth-scroll` version `0.8.1` or later. If the issue persists or for older versions, ensure the plugin or scrolling logic is only executed client-side or properly guarded within `if (typeof window !== 'undefined')` checks.
Consider using `html { scroll-behavior: smooth; }` in your CSS if advanced features like specific offsets, custom easing functions, programmatic control, or custom scroll containers are not required.Update `vue3-smooth-scroll` to version `0.8.1` or newer, as this version specifically addresses SSR compatibility. If using an older version or if the error persists with custom logic, ensure client-side code is conditionally executed (`if (typeof window !== 'undefined')`) or wrapped in SSR-aware components (e.g., `<ClientOnly>` in Nuxt).
No dependency data recorded yet.