useDocumentTitle

Update the document title.

https://www.shaktools.com/shak-hooks
Browser

API Reference

Installation

terminal
pnpm add @shak-hooks/usehooks
import.ts
import { useDocumentTitle } from "@shak-hooks/usehooks";
Source: packages/react/src/useDocumentTitle.ts

Signature

signature.ts
export function useDocumentTitle(title: string, options: UseDocumentTitleOptions = {})

Parameters

NameTypeOptionalDefault
titlestringNo-
optionsUseDocumentTitleOptionsYes{}

Returns

unknown

Exported Types

types.ts
1export interface UseDocumentTitleOptions {
2 restoreOnUnmount?: boolean;
3}

Implementation

use-document-title.ts
1import { useEffect } from "react";
2
3export function useDocumentTitle(title: string) {
4 useEffect(() => {
5 document.title = title;
6 }, [title]);
7}

Advertisement

Google Ads

Usage

example.tsx
1import { useDocumentTitle } from "@shak-hooks/usehooks";
2
3const result = useDocumentTitle("...", undefined);
4// result: unknown
5// Use values directly (React state).

Let‘s do great work together

Empowering creators with free, high-performance AI, SEO, and developer tools. Join thousands of users optimizing their workflow with Shak-Tools.

Tools10+ Free
UsersGlobal

Stay in the loop

Join our newsletter for the latest AI tools and updates.

ShakTools
© 2025 Shaktools. All Rights Reserved.Privacy Policy