Hooks
/ API Reference
Hooks
/ API Reference

useClientOnly

A hook that returns a boolean indicating whether the component is mounted on the client side.

The Gist

'use client'
import { useClientOnly } from '@weser/hooks'

function Component() {
  const isClientOnly = useClientOnly()

  if (!isClientOnly) {
    return null
  }

  return <div>I only render on the client side</div>
}

Returns

(boolean) A boolean indicating whether the component is mounted on the client side.

On this page