alepha@docs:~/docs/.content/release/framework/docs/reference/react-hooks$
cat useHead.md | pretty1 min read
Last commit:
#useHead
#Import
typescript
1import { useHead } from "alepha/react/head";
#Overview
Read and update the document head (title, meta, …) from a component.
The SEO fields (description, image, url, ...) expand into their meta
and link tags, as in a page's head. The returned head reads the document
when asked: it is not state, and setHead does not render the component
again.
tsx
1const App = () => { 2 const [, setHead] = useHead({ 3 // will set the document title on the first render 4 title: "My App", 5 }); 6 7 return ( 8 // This will update the document title when the button is clicked 9 <button onClick={() => setHead({ title: "Change Title" })}>10 Change Title11 </button>12 );13};