Utility
ClientOnly
A component that only renders its children on the client-side, preventing hydration mismatches between server and client rendering.
Import
Code
Props
Code
Usage
Basic Usage
Code
With Fallback
Code
Examples
Code
Use Cases
- Browser APIs: Components that use
window
,document
, or other browser-only APIs - Third-party Libraries: Libraries that don't support SSR
- Theme Switches: Preventing flash of incorrect theme
- Interactive Widgets: Components with complex client-side state
- Conditional Features: Features that should only appear on the client
Notes
Use ClientOnly sparingly as it can impact SEO and initial page load performance. Only use it when necessary for components that cannot be server-rendered.
Always provide a meaningful fallback that matches the approximate size and layout of your client-only component to prevent layout shifts.
Last modified on