vue3-lazy-hydration is a library designed for Vue 3 applications utilizing Server-Side Rendering (SSR) to improve initial page load performance by delaying the hydration of pre-rendered HTML components. Instead of immediately making all components interactive on the client, it allows developers to specify conditions under which hydration should occur, such as when the browser is idle, when a component becomes visible in the viewport, or upon user interaction (e.g., click, focus). The library provides a flexible API including a renderless component (`LazyHydrationWrapper`), composables like `useLazyHydration`, and import wrappers for controlling hydration. The current stable version is 1.2.1. While the project saw several updates in 2022, its release cadence has since become dormant, with the last update in September 2022. It distinguishes itself by offering multiple hydration strategies and direct Vue 3 compatibility, building upon concepts from its Vue 2 predecessor.
npm install vue3-lazy-hydrationVerified import paths — ran on the pinned version, not inferred.
This example demonstrates various lazy hydration strategies using the `LazyHydrationWrapper` component. It shows how to delay hydration until the browser is idle, when the component becomes visible in the viewport, or upon specific user interactions like click or touchstart. Each method logs a message and triggers an alert when the component successfully hydrates.
Upgrade to `vue3-lazy-hydration@1.2.1` or newer using `npm install vue3-lazy-hydration@latest` or `yarn add vue3-lazy-hydration@latest`.
Evaluate if the current feature set meets your needs and consider the lack of ongoing support when planning for future updates or specific bug fixes. Keep an eye on the GitHub repository for any unexpected activity.
Always provide at least one condition prop (e.g., `:when-idle`, `:when-visible`, `:on-interaction`) to ensure your component eventually hydrates and becomes interactive. If manual control is desired, use the `:manual` prop.
Update to `vue3-lazy-hydration@1.2.1` or newer by running `npm install vue3-lazy-hydration@latest` or `yarn add vue3-lazy-hydration@latest`.
Ensure you provide a hydration trigger prop like `:when-idle`, `:when-visible`, `:on-interaction`, or `:manual` to the `LazyHydrationWrapper` component. Without these, the component will not hydrate and remain static.
Verify the import statement `import { ... } from 'vue3-lazy-hydration';` is correct. Ensure the package is properly installed by running `npm install vue3-lazy-hydration` or `yarn add vue3-lazy-hydration`.