useHydration

Commons
stable

Returns a shallow ref that is false during SSR and true once the component has mounted in the browser. In non-SSR mode it resolves immediately to true. Use it to guard client-only rendering branches without causing hydration mismatches.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

useHydration delegates to useDisplay().ssr to detect the SSR context. Outside the browser it returns shallowRef(false) immediately, skipping the onMounted registration entirely.

API

Return values

Properties and methods exposed by the composable return object.

isMounted
false during SSR and on the first render pass; true once onMounted fires. Always true in a non-SSR context.

Usage

Examples

Ready-to-paste usage snippets.

Guard a client-only component

vue

Deferred computation until hydrated

ts