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-head-safe

v1.0.2

Published

A lightweight React head manager for CSR apps. Safely manage document title, meta tags, Open Graph, and SEO metadata without duplicates. TypeScript support included.

Readme

react-head-safe

npm version npm downloads codecov

English | 한국어

A lightweight React head manager for client-side rendering (CSR) applications.

Safely manage document title, meta tags, Open Graph tags, and SEO metadata without duplicates. Perfect for React SPAs, Vite, and Create React App projects.

Why react-head-safe?

A lightweight, CSR-focused alternative for managing document head elements in React. Perfect for simple client-side rendered applications that need:

  • Explicit duplicate prevention - Always removes existing meta tags before adding new ones
  • Simplicity - Just a single component with props, no complex setup
  • Performance - Uses useLayoutEffect for synchronous DOM updates before paint
  • Type safety - Written in TypeScript with full type definitions

Features

  • No Duplicate Tags - Removes existing meta tags before creating new ones
  • TypeScript Support - Full type safety with TypeScript
  • Lightweight - Zero dependencies except React
  • CSR Optimized - Uses useLayoutEffect for synchronous DOM updates
  • Open Graph Support - Built-in support for social media meta tags
  • Simple API - Just pass props, no complex configuration

Installation

Install via npm, yarn, or pnpm:

npm install react-head-safe
# or
yarn add react-head-safe
# or
pnpm add react-head-safe

Zero dependencies required (React is a peer dependency).

Quick Start

Simply import and use the ReactHeadSafe component in your React pages:

import { ReactHeadSafe } from 'react-head-safe';

function MyPage() {
  return (
    <>
      <ReactHeadSafe
        title="My Page Title"
        description="This is the page description for SEO."
        keywords="react,seo,meta tags"
        ogTitle="My Page Title for Social Media"
        ogDescription="This is the description for social media."
        ogImage="https://example.com/image.jpg"
      />
      <div>Your page content...</div>
    </>
  );
}

That's it! The component will automatically:

  • Set the document title
  • Add/update meta description and keywords
  • Add/update Open Graph tags for social media
  • Remove any duplicate tags

API Reference

ReactHeadSafeProps

| Prop | Type | Description | | --------------- | -------- | -------------------------------------------------------------------- | | title | string | The page title that will be set in the document.title | | description | string | The meta description tag content for SEO | | keywords | string | The meta keywords tag content for SEO | | ogTitle | string | The Open Graph title (og:title) for social media sharing | | ogDescription | string | The Open Graph description (og:description) for social media sharing | | ogImage | string | The Open Graph image URL (og:image) for social media sharing |

Local Development

To test your local changes with the example application:

pnpm run example

Testing

This project uses Vitest and React Testing Library for comprehensive unit testing with high code coverage.

Running Tests

# Run tests once
pnpm test

# Run tests in watch mode
pnpm test:watch

# Run tests with coverage
pnpm test:coverage

# Run tests with UI
pnpm test:ui

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Build the library
pnpm build

# Run example app
pnpm example

License

MIT © umsungjun


Keywords: react head manager, react meta tags, react seo, open graph react, react helmet alternative, csr meta tags, spa seo, client-side rendering seo, react document head, vite meta tags