raddix

useDocumentTitle

Dynamically update the title of a web page.

Installation

Install the custom hook from your command line.

npm i @raddix/use-document-title

Usage

import { useState } from 'react';
import { useDocumentTitle } from '@raddix/use-document-title';
export default function App() {
const [count, setCount] = useState(0)
useDocumentTitle(`Clicked ${count} times.`);
return (
<button onClick={() => setCount(count + 1)}>
Increment Count: {count}
</button>
)
}

API

Parameters

NameDescriptionType
titleThe title to be set for the document.string