usePageTitle
Alias of useDocumentTitle.
Import
TypeScript
import { usePageTitle } from '@/hooks';API
Signature
usePageTitle(title, options?)
When to use
Use usePageTitle instead of re-implementing the same pattern in multiple components.
SSR / Next.js
Browser utilities are SSR-gated; lifecycle hooks are safe.
Live playground
Edit the example and see it run against the real @/hooks package in this app.
Live playgroundEdit · run with real
@/hooks · usePageTitleEditor
function Page({ title }: { title: string }) { usePageTitle(title); return <h1>{title}</h1>; }
Preview
Implementation source
Full library source for usePageTitle — copy into your project when you are not installing a package yet.
hooks/utility/usePageTitle.ts
import {
useDocumentTitle,
type UseDocumentTitleOptions,
} from './useDocumentTitle';
/** Alias of {@link useDocumentTitle}. */
export function usePageTitle(
title: string,
options?: UseDocumentTitleOptions,
): void {
useDocumentTitle(title, options);
}
Copy-paste example
usePageTitle.example.tsx
'use client';
import { usePageTitle } from '@/hooks';
export function Page({ title }: { title: string }) {
usePageTitle(title);
return <h1>{title}</h1>;
}Production checklist
- Called only from Client Components or other custom hooks
- Type parameters filled in (e.g.
useFetch<User[]>) - Tip: Lifecycle hooks are for side effects only — not for deriving render state.
- Source of truth: open
hooks/utility/usePageTitle.tsfor implementation details