@usefy/use-document-title
v0.25.1
Published
A React hook for setting document.title with restore-on-unmount
Maintainers
Readme
Overview
useDocumentTitle is part of the @usefy ecosystem — a collection of production-ready, TypeScript-first, SSR-safe React hooks. Set document.title with restore-on-unmount.
Features
- Reactive — updates the tab title whenever the value changes
- Restore on unmount — optionally put the previous title back
- SSR-safe — no-op when
documentis unavailable - TypeScript-first — full type inference and exported types
- Tiny & tree-shakeable — zero dependencies, published as its own package
Installation
# npm
npm install @usefy/use-document-title
# yarn
yarn add @usefy/use-document-title
# pnpm
pnpm add @usefy/use-document-titleRequires React 18 or 19 (peerDependencies: "react": "^18.0.0 || ^19.0.0").
Quick Start
import { useDocumentTitle } from "@usefy/use-document-title";
useDocumentTitle(`Inbox (${unread})`);API
useDocumentTitle(title, options?) — options.restoreOnUnmount (default false) restores the title present at mount when the component unmounts.
Testing
📊 View Detailed Coverage Report (GitHub Pages) — 5 tests, 92% statement coverage.
License
MIT © mirunamu
This package is part of the usefy monorepo.
