Menu

Vue Lazy Hydration: Ship the HTML Now, Hydrate the Component Later
📰

Vue Lazy Hydration: Ship the HTML Now, Hydrate the Component Later

DEV Community: vue·Danny Holloran·2 days ago
#3QCMKY6L
#devtovue#devto#dev#hydrate#component
Long article (1063 words) — no AI summary yet.
Reading 0:00
15s threshold

Server-side rendering gets your HTML on screen fast. Then the browser downloads every component's JavaScript, runs it, and walks the DOM to attach listeners, all before the page is fully interactive. The footer newsletter form, the comments section three screens down, the "related products" carousel nobody scrolls to: they all hydrate on page load whether anyone touches them or not.

That's the cost lazy hydration targets. Since Vue 3.5, an async component can decide when it hydrates. The server still renders its full HTML, so users and crawlers see the content immediately, but the component's JavaScript isn't fetched or run until a condition you pick is met.

The four built-in strategies

Lazy hydration hangs off defineAsyncComponent , which you may already use for code splitting. You add a hydrate option and pass it one of the strategy functions.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.