Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zayne-labs/ui/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheClientGate component ensures that its children are only rendered after JavaScript has loaded on the client side. This is useful for preventing hydration mismatches and for components that require browser APIs.
Import
Props
The content to render only on the client side. Can be a render function for lazy evaluation.
Content to render on the server or before hydration. It’s recommended to use a fallback with the same dimensions as the client-rendered children to avoid content layout shift.
Usage Examples
Basic Usage
With Render Function
Preventing Layout Shift
FakeChart should have the same dimensions (400x300) as RealChart to prevent layout shift during hydration.
Browser-Only Components
Multiple Client-Only Sections
Notes
- The component uses the
useIsHydratedhook internally to detect when the client has hydrated - When no fallback is provided, nothing is rendered on the server
- Using a fallback with matching dimensions prevents Cumulative Layout Shift (CLS)
- Render functions are useful for lazy loading or accessing browser-only APIs