Question presented to candidate: "Our server-rendered product page is visible quickly, but it takes a long time before anything responds to a tap, because every widget hydrates on load. Vue 3.5 added lazy hydration. Explain how it works, which strategies exist, and what it does and does not save us."
What a strong answer should cover:
- Lazy hydration is configured per async component with the
hydrateoption ofdefineAsyncComponent, and only applies when hydrating SSR markup. - The built-in strategies:
hydrateOnIdle(timeout),hydrateOnVisible(observerOptions),hydrateOnInteraction(events)andhydrateOnMediaQuery(query), plus custom strategies with the(hydrate, forEachElement) => teardownsignature. - Until it hydrates, the component is static server HTML: visible, but its listeners are not attached.
hydrateOnInteractionreplays the triggering event after hydrating; it needs an explicit event list in plain Vue.- In plain Vue the loader still runs at mount: the strategy defers hydration work, not the download. Nuxt's
hydrate-on-*props wrap it differently. - A prop change from the parent forces immediate hydration.
Clarifying questions expected:
- "Which widgets are below the fold or rarely used?"
- "Are we on plain Vue SSR or Nuxt? The ergonomics and what gets deferred differ."
Code / implementation expected: Optional — defineAsyncComponent({ loader, hydrate: hydrateOnVisible() }), or a small custom strategy.