Rehooks

useIsClient

Determines if the component is rendered on the client side.

useIsClient

Installation

npx rehooks-cli@latest add useIsClient

Usage

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

API

useIsClient

useIsClient.ts
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