Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

useHydration


IntermediateApr 5, 2026

Control SSR hydration timing to prevent mismatches and optimize client-side rendering.

Installation

Install the Hydration plugin in your app’s entry point:

main.ts
import { createApp } from 'vue'
import { createHydrationPlugin } from '@vuetify/v0'
import App from './App.vue'

const app = createApp(App)

app.use(createHydrationPlugin())

app.mount('#app')

Usage

Once the plugin is installed, use the useHydration composable in any component. Destructure the properties for automatic ref unwrapping in templates:

vue
<script setup lang="ts">
  import { useHydration } from '@vuetify/v0'

  const { isHydrated, isSettled } = useHydration()

  // In script, access .value
  if (isHydrated.value) {
    console.log('Hydration complete')
  }
</script>

<template>
  <div>
    <!-- Destructured refs auto-unwrap in templates -->
    <p v-if="isHydrated">
      Application is hydrated - browser features available
    </p>
    <p v-else>
      Rendering on server or waiting for hydration
    </p>
  </div>
</template>

Architecture

useHydration uses the plugin pattern with a simple boolean state:

Hydration Plugin

Use controls to zoom and pan. Click outside or press Escape to close.

Hydration Plugin

Reactivity

All properties are Readonly<ShallowRef> and update when the root component mounts. Use .value in script; destructure for template auto-unwrapping.

PropertyTypeNotes
isHydratedShallowRef<boolean>True after root component mounts
isSettledShallowRef<boolean>True after next tick post-hydration

Fallback Hydration

When useHydration() is called without the plugin installed (no createHydrationPlugin in your app), it returns a fallback context where isHydrated and isSettled are immediately true. This means components that conditionally render based on isHydrated work correctly in client-only apps without any plugin setup.

ts
// Without plugin: isHydrated.value === true immediately
// With plugin:    isHydrated.value starts false, becomes true after mount
const { isHydrated } = useHydration()
Tip

The fallback is also what SSR-aware composables like useResizeObserver use internally — they call useHydration() to defer observation until after hydration, but work correctly even in environments where the plugin isn’t installed.

Examples

Hydration State

Displays the live isHydrated and isSettled states as the component mounts and the next tick resolves, illustrating the SSR hydration lifecycle.

isHydrated
false

True after root component mounts

isSettled
false

True one tick after hydration, safe for animations

pending
Waiting for root component to mount.
Lifecycle
SSR
hydrate()
nextTick
settle()

API Reference

The following API details are for the useHydration composable.

Functions

createHydration

() => E

Creates a new hydration instance.

createHydrationContext

<_E>(_options?: HydrationContextOptions | undefined) => ContextTrinity<_E>

createHydrationPlugin

(_options?: HydrationContextOptions | undefined) => Plugin

useHydration

<_E>(namespace?: string) => _E

Properties

isHydrated

Readonly<ShallowRef<boolean>>

True when root component has mounted (hydration complete)

isSettled

Readonly<ShallowRef<boolean>>

True after first tick post-hydration (safe for animations after state restoration)

Methods

hydrate

() => void

Mark hydration as complete

settle

() => void

Mark as settled (called automatically after nextTick post-hydration)

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/