useDocumentTitle()
An easy way to set the title of the current document.
The Hook
1import { useIsomorphicLayoutEffect } from 'usehooks-ts'23function useDocumentTitle(title: string): void {4 useIsomorphicLayoutEffect(() => {5 window.document.title = title6 }, [title])7}89export default useDocumentTitle
Usage
1import { useDocumentTitle } from 'usehooks-ts'23export default function Component() {4 useDocumentTitle('foo bar')5}
See a way to make this page better?
Edit there »