Rehooks
Content

useIsClient

Custom hook that determines if the component is being rendered on the client side.

useIsClient

Usage

Component.tsx
import { useIsClient } from "~/hooks/useIsClient";
 
function Component() {
  const isClient = useIsClient();
 
  return <div>{isClient ? "Client" : "Server"}</div>;
}

API

useIsClient

function useIsClient(): boolean;

A custom React hook that determines if the component is being rendered on the client side.

Returns

NameTypeDescription
isClientbooleanReturns true if the component is mounted on the client, false otherwise.

On this page