Utilities
Client only

Client Only

Render content only on the client side.

Motivation

The ClientOnly component renders its children only on the client side. This is useful for components that need to access the DOM or browser APIs that are not available on the server side.

Examples

Basic

import { ClientOnly } from '../client-only'

export const Basic = () => (
  <ClientOnly>
    <div>This content is only rendered on the client side.</div>
  </ClientOnly>
)

With Fallback

import { ClientOnly } from '../client-only'

export const WithFallback = () => (
  <ClientOnly fallback={<div>Loading...</div>}>
    <div>This content is only rendered on the client side.</div>
  </ClientOnly>
)

API Reference

ClientOnly

PropDefaultType
fallback
string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>

Pro Support and Training

Supercharge your team with support from the creators of Ark UI

Get Pro Support