useDocumentTitle

About

Sets the document title and optionally resets the title on unmount

Examples

Basic example

import { useDocumentTitle } from "rooks";

function App() {
  useDocumentTitle("New document title");

  return (
    <div>
      <h1>Document title is now "New document title"</h1>
    </div>
  );
}

export default App;


## Examples

### Basic example

```jsx
import { useDocumentTitle } from "rooks";

function App() {
  useDocumentTitle("New document title");

  return (
    <div>
      <h1>Document title is now "New document title"</h1>
    </div>
  );
}

export default App;

Example with reset

import { useDocumentTitle } from "rooks";

function App() {
  useDocumentTitle("New document title", { resetOnUnmount: true });

  return (
    <div>
      <h1>
        Document title is now "New document title" and will be reset on unmount
      </h1>
    </div>
  );
}

export default App;

Arguments

ArgumentTypeDescription
titlestringThe new document title
optionsobjectOptions object
options.resetOnUnmountbooleanWhether to reset the document title on unmount

Return

void

Join the community!

Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!

Powered by vercel