useTitle
A React Hook that helps to manage the title of the document.
Demo
Usage
See API for more details.
Source
Click links below to view source on GitHub.
API
const restore = useTitle(newTitle, options)
NewTitle
A string that represents the new title of the document.
Options
/**
 * `%s` will be replaced by the title if the template is a `string`
 */
export type UseTitleOptionsTemplate = string | ((title: string) => string)
export type UseTitleOptions = {
  /**
   * Restore the original title when unmounted
   *
   * @defaultValue false
   */
  restoreOnUnmount?: boolean
  /**
   * A template to format the title
   *
   * @defaultValue '%s'
   */
  template?: UseTitleOptionsTemplate
}
Returns
A function to restore to the original title.