npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-roof

v1.1.0

Published

Efficient React HTML head manager for SEO and social media sharing. Use `ReactRoof` to manage your document head, including titles, meta tags, scripts, and structured data, with a dedicated SEO component for simplified social card generation.

Readme

ReactRoof

Efficient React HTML head manager for SEO and social media sharing. Use ReactRoof to manage your document head, including titles, meta tags, scripts, and structured data, with a dedicated SEO component for simplified social card generation.

Features

  • Lightweight & Fast: Designed for modern React applications.
  • Component-Based: Manage your <head> tags using standard React components.
  • SEO Ready: Includes a dedicated <SEO /> component for easy Open Graph, Twitter Card, and JSON-LD management.
  • Type Safe: Built with TypeScript for excellent autocomplete and validation.
  • Standard API: Supports <title>, <meta>, <link>, and <script> tags directly.
  • Nested Support: Child components can override parent tags ("Last one wins" strategy).

Installation

Before installing, please note that the library isn't compatible with React v19 yet as it uses the stable version of 18.3

npm install react-roof
# or
yarn add react-roof
# or
pnpm add react-roof

Note: ReactRoof v1.1.0+ requires React v19.0.0 or higher.

Basic Usage

Wrap your application in RoofProvider (for backward compatibility), then use the <Head> component anywhere in your component tree.

import { RoofProvider, Head } from "react-roof";

function App() {
  return (
    <RoofProvider>
      <HomePage />
    </RoofProvider>
  );
}

function HomePage() {
  return (
    <>
      <Head>
        <title>My Awesome App</title>
        <meta name="description" content="This is the home page" />
      </Head>
      <h1>Welcome Home</h1>
    </>
  );
}

The <SEO /> Component

For most pages, you want to set standard social sharing tags without repetitive boilerplate. Use the <SEO /> component for this.

import { SEO } from "react-roof";

function BlogPost() {
  return (
    <SEO
      title="Understanding React Hooks"
      description="A deep dive into useState and useEffect."
      image="https://example.com/hooks-cover.jpg"
      type="article"
      twitter={{
        card: "summary_large_image",
        site: "@mydevblog",
      }}
    />
  );
}

Supported Props

| Prop | Type | Description | | ------------- | -------------------- | --------------------------------------------------------------------- | | title | string | Sets <title>, og:title, and twitter:title. | | description | string | Sets meta description, og:description, and twitter:description. | | image | string | object | Sets og:image. Supports object for width, height, alt. | | url | string | Sets canonical og:url. | | type | string | Sets og:type (default: "website"). Support "article", "video", etc. | | twitter | object | Customize Twitter card specific fields (card, site, creator). | | jsonLd | object | array | Automatically injects safe JSON-LD structured data scripts. |

Advanced Usage: Articles & JSON-LD

<SEO
  // ... basic props
  type="article"
  article={{
    publishedTime: "2024-01-01T12:00:00Z",
    author: ["Jane Doe"],
    tags: ["React", "JavaScript"],
  }}
  jsonLd={{
    "@context": "https://schema.org",
    "@type": "Article",
    headline: "Understanding React Hooks",
    author: {
      "@type": "Person",
      name: "Jane Doe",
    },
  }}
/>

Component API

<Head>

The core component that allows React 19 to hoist its children to the document head.

  • Supports standard HTML tags: <title>, <meta>, <link>, <script>.
  • React 19 handles tag hoisting and lifecycle automatically.
  • No more manual DOM manipulation or data-attributes!
<Head>
  <title>Raw Control</title>
  <meta name="theme-color" content="#000000" />
  <link rel="canonical" href="https://custom.url" />
  <script src="https://analytics.example.com/js" async />
</Head>

Principles (React 19 Native)

  1. Native Hoisting: React 19 natively recognizes <title>, <meta>, and <link> tags and automatically hoists them to the <head>. Because React appends tags in the order they are rendered (parents then children), the browser naturally respects the child's tag as the "winner."

    <!-- Resulting DOM structure in React 19 -->
    <head>
      <title>Parent Title</title>
      <title>Child Title</title>
      <!-- Browser uses the last one encountered -->
    </head>
  2. Resource Lifecycle: Tags are managed by React's internal resource manager. When a component unmounts, React correctly handles the removing or updating of the associated head tags.

  3. No Boilerplate: ReactRoof provides the high-level abstractions (<SEO />, <Head />) you need while letting React handle the low-level DOM work.

License

MIT