Detect when a React component has fully mounted on the client-side. Extremely useful for avoiding hydration mismatches when rendering browser-only features.
const isMounted = useMounted();
Trigger a remount to observe the client-side mounting transition.
useMounted() => false
⏳ Preparing client-side activation...
SSR / HTML Output
`useMounted()` returns false. Safe fallback markup is generated on the server.
Hydration Trigger
React binds events. `useEffect` runs. `useMounted` transitions to true on the next tick.
Client-Safe Hydration Complete
State synced, dynamic browser-only features are now fully functional and visible.
import { useMounted } from 'kitzo'; function ClientOnly({ children }: { children: React.ReactNode }) { const isMounted = useMounted(); if (!isMounted) { // Render an empty state or a server-safe fallback skeleton during SSR/hydration return <div className="h-20 animate-pulse bg-neutral-100 dark:bg-neutral-800 rounded-lg" />; } // Safe to render browser-only APIs or components after mounting return <>{children}</>; }
This hook does not accept any parameters.
| Type | Description |
|---|---|
boolean | Returns |
Returns a simple boolean indicating the component's mount status.
false on the server and initial client render, then transitions to true immediately after hydration.window, document, or localStorage).