@usefy/use-is-first-render
v0.25.1
Published
A React hook that returns true only on the first render
Maintainers
Readme
Overview
useIsFirstRender is part of the @usefy ecosystem — a collection of production-ready, TypeScript-first, SSR-safe React hooks. Returns true only on the first render.
Features
- Ref-based — flips during render, no extra re-render
- Per-instance — each component tracks its own first render
- Simple — returns a boolean
- 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-first-render
# yarn
yarn add @usefy/use-is-first-render
# pnpm
pnpm add @usefy/use-is-first-renderRequires React 18 or 19 (peerDependencies: "react": "^18.0.0 || ^19.0.0").
Quick Start
import { useIsFirstRender } from "@usefy/use-is-first-render";
const isFirst = useIsFirstRender();
if (!isFirst) onValueChange(value);API
useIsFirstRender(): boolean — true on the first render, false on every render thereafter.
Testing
📊 View Detailed Coverage Report (GitHub Pages) — 3 tests, 100% statement coverage.
License
MIT © mirunamu
This package is part of the usefy monorepo.
