use-document-title

A React hook that sets the current title of the document.

Basic Usage

import useDocumentTitle from '@tanem/use-document-title'
import React from 'react'
import ReactDOM from 'react-dom'

const App = ({ title }) => {
  useDocumentTitle(title)
  return <div />
}

ReactDOM.render(<App title="New title" />, document.getElementById('root'))
React JSX

Live Examples

API

Arguments

  • title - The new title of the document.

Example

useDocumentTitle('New title')
React JSX

Installation

$ npm install @tanem/use-document-title --save

There are also UMD builds available via unpkg:

For the non-minified development version, make sure you have already included:

For the minified production version, make sure you have already included:

GitHub

:fishing_pole_and_fish: A React hook that sets the current title of the document.Read More

Latest commit to the master branch on 3-24-2025
Download as zip