When to Use
- Render components that depend on browser APIs (window, document, etc.)
- Prevent hydration mismatches from client-only features
- Show skeleton loaders during hydration
- Progressively enhance server-rendered content
- Handle components that require JavaScript to function
Basic Usage
Component API
React.ReactNode | (() => React.ReactNode)
required
Content to render after client-side hydration. Can be a render function for deferred initialization
React.ReactNode
Content to show during SSR or before hydration. Should match the dimensions of the hydrated content to avoid layout shift
You are encouraged to add a fallback that matches the dimensions of the client-rendered children to avoid content layout shift.
Examples
Browser API-Dependent Component
Chart with Skeleton Fallback
Third-Party Widget
Window Size Dependent Component
Comparison to Native Patterns
Traditional Approach
With ClientGate
Common Use Cases
Progressive Enhancement
Preventing Hydration Mismatches
Implementation Details
The component uses theuseIsHydrated hook internally to detect when the client has hydrated: