@usefy/use-is-client
v0.25.1
Published
A React hook that returns true once the component has hydrated on the client (SSR-safe)
Maintainers
Readme
Overview
useIsClient is part of the @usefy ecosystem — a collection of production-ready, TypeScript-first, SSR-safe React hooks. Returns true once the component has hydrated on the client (SSR-safe).
Features
- SSR-safe — the first render matches the server output
- Zero config — no arguments, returns a boolean
- Hydration guard — enable client-only UI only after mount
- TypeScript-first — full type inference and exported types
- Tiny & tree-shakeable — zero dependencies, published as its own package
Installation
# npm
npm install @usefy/use-is-client
# yarn
yarn add @usefy/use-is-client
# pnpm
pnpm add @usefy/use-is-clientRequires React 18 or 19 (peerDependencies: "react": "^18.0.0 || ^19.0.0").
Quick Start
import { useIsClient } from "@usefy/use-is-client";
const isClient = useIsClient();
return isClient ? <ClientOnly /> : <ServerFallback />;API
useIsClient(): boolean — false on the server and the first render, true after hydration.
Testing
📊 View Detailed Coverage Report (GitHub Pages) — 4 tests, 100% statement coverage.
License
MIT © mirunamu
This package is part of the usefy monorepo.
