ClientOnly

ClientOnly is a component that renders its children only on the client side.

Usage

import { ClientOnly } from "@yamada-ui/react"
<ClientOnly />

Fallback

To render a loading state while child elements are being prepared, use the fallback prop.

Render Prop

When your component accesses browser-only APIs like window, document, localStorage, use the render prop pattern. This pattern ensures that components accessing browser APIs are evaluated only on the client side, preventing hydration mismatches and server-side errors.
It can also be used for rendering heavy components that are not needed on the server side.

/* This may cause server-side errors */
<ClientOnly fallback={<Skeleton />}>
  <ComponentThatUsesWindow />
</ClientOnly>

/* This is safe */
<ClientOnly fallback={<Skeleton />}>
  {() => <ComponentThatUsesWindow />}
</ClientOnly>

Props

Similar Components

Show

Show is a component that shows or hides its children based on a condition.

For

For is a component used to loop over an array and render a component for each item.

Format

Format is used to format dates, numbers, and bytes according to a specific locale.

Portal

Portal is a component that renders elements outside of the current DOM hierarchy.

Slot

Slot is a component that merges its props onto its immediate child.

Uses Components & Hooks