Hooks to populate the html head.
Hoofd is a powerful library designed to enhance your web application by providing a set of hooks that simplify the management of <head> elements in your HTML documents. With the growing importance of SEO and ensuring your website is crawler-friendly, Hoofd ensures that your pages have the right metadata, even if they’re rendered client-side. Its seamless integration with popular frameworks like Preact and Gatsby makes it a versatile choice for developers looking to optimize how their applications handle metadata.
Whether you’re setting up titles, meta tags, or links, Hoofd offers a structured way to manage these aspects efficiently. Its focus on server-side rendering (SSR) and client-side rendering (CSR) also ensures that your application remains performant while catering to the needs of various web crawlers.
useTitle: This hook allows you to set the document title dynamically. It updates the title whenever the specified string changes, ensuring your page reflects the current context.
useTitleTemplate: Similar to useTitle, this hook formats the title based on a template string, replacing a placeholder with the actual title for more flexibility in presentation.
useMeta: Accepting standard <meta> properties, this hook updates metadata dynamically based on the input object, allowing for fine-grained control over page information.
useLink: Manage your linking easily with this hook, which accepts <link> properties. Updates are seamless and maintain consistency within the same instance.
useLang: This hook allows you to set the lang attribute on the base <html> tag, enhancing accessibility and SEO by reflecting changes in the document’s language.
useScript: Offers a comprehensive way to inject script tags dynamically, catering to SSR and CSR needs with options for src, text, and various script attributes.
SSR Support: The toStatic method consolidates key properties such as title, lang, metas, and links, tailored for improved compatibility with frameworks like Gatsby.
Gatsby Integration: A dedicated plugin ensures that your Gatsby applications can harness the power of Hoofd to manage metadata efficiently during the build process.