| 1 | "use client"; |
| 2 | |
| 3 | import { useSyncExternalStore } from |
| 4 | |
| 5 | /** Returns `true` once the component is mounted on the client (hydrated) and `false` while rendering on the server, so client-only reads (e.g. `sessionStorage`) stay safe during SSR. */ |
| 6 | export function useIsHydrated() |
| 7 | const subscribe = |
| 8 | return useSyncExternalStore( |
| 9 | subscribe, |
| 10 | () => true, |
| 11 | () => false, |
| 12 | ); |
| 13 | } |