ZuploZuplo
LoginStart for Free
  • Documentation
  • API Reference
Introduction
Getting Started
    Develop using the Portal
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingMCP - Quick start
    Develop Locally
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth
Concepts
Development
Policies
Handlers
API Keys
MCP Server
MCP Gateway
AI Gateway
Developer Portal
    IntroductionLocal DevelopmentUpdating VersionsNode Modules & Customization
    Configuration
    Writing
    OpenAPI
    Authentication
    Integrations
    Guides
    Extending
    Components
      General
      Documentation
      Form
      Utility
        ClientOnlyHeadSlot
Monetization
Deploying & Source Control
Observability
Networking & Infrastructure
Account Management
Programming API
Build with AI
Zuplo CLI
Migration Guides
Platform LimitsSecuritySupportTrust & ComplianceChangelog
powered by Zudoku
Utility

ClientOnly

A component that only renders its children on the client-side, preventing hydration mismatches between server and client rendering.

Import

Code
import { ClientOnly } from "zudoku/components";

Props

Code
type ClientOnlyProps = { children: ReactNode; fallback?: ReactNode; };

Usage

Basic Usage

Code
<ClientOnly> <SomeClientOnlyComponent /> </ClientOnly>

With Fallback

Code
<ClientOnly fallback={<div>Loading...</div>}> <InteractiveWidget /> </ClientOnly>

Examples

Code
function MyComponent() { return ( <div> <h1>This renders on both server and client</h1> <ClientOnly fallback={<Spinner />}> <ComponentThatUsesWindowObject /> </ClientOnly> </div> ); }

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.

Edit this page
Last modified on May 29, 2026
LabelHead
On this page
  • Import
  • Props
  • Usage
    • Basic Usage
    • With Fallback
  • Examples
  • Use Cases
  • Notes
React
TypeScript
React
React
React