Skip to content

useHydration

True once the component has mounted on the client.

useHydration() is false on the server and on the first render in the browser, then true. Branch on it for anything the server cannot know: the time zone, the language, a choice kept in localStorage, a store that rehydrates. Both renders agree, so React reports no hydration mismatch. Until it is true, render a placeholder of the same size, such as a @khaeli/skeleton, so nothing jumps.

A value only the browser knows

Time zone
Language

A stored choice

  • Review the pricing page copy
  • Confirm the launch date
  • Send the release notes

Installation

npx shadcn@latest add @khaeli/use-hydration

Installs with

Nothing else. This item needs no other Registry item and no npm package.

Accessible name

  • A control whose value is not known yet stays in the page, disabled, with its label. It becomes usable in the same place once the value is read.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/use-hydration.json