Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 760 Bytes

File metadata and controls

33 lines (23 loc) · 760 Bytes

useIsClient

useIsClient is a React hook that returns true only in the client-side environment. It is primarily used to differentiate between client-side and server-side rendering (SSR). The state is set to true only after the component is mounted in the client-side environment.

Interface

function useIsClient(): boolean;

Return Value

Example

import { useIsClient } from 'react-simplikit';

function ClientSideContent() {
  const isClient = useIsClient();

  if (!isClient) {
    return <div>Loading...</div>;
  }

  return <div>Client-side rendered content</div>;
}