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-meta-hooks

v1.0.5

Published

Modern React hooks for managing SEO meta tags, document head, Open Graph, and JSON-LD structured data.

Downloads

48

Readme

react-meta-hooks

Modern React hooks for managing SEO, Open Graph, and document head.

A modern, fast, TypeScript-first React npm package for managing <head> metadata.

npm version License: MIT

react-meta-hooks provides hook-centric APIs to manage your page's <head> tags (title, meta tags, links) efficiently. It supports both client-side rendering and SSR with request-scoped context isolation.

Features

  • ⚛️ Hook-centric API: Clean and intuitive hooks like useTitle, useMeta, useSocialMeta, and useStructuredData.
  • Lightweight & Fast: Batches DOM updates for optimal performance.
  • 🧱 Context Isolation: <MetaProvider> ensures SSR thread-safety and isolates metadata per request.
  • 🛠 TypeScript First: Full type safety out of the box.

Installation

npm install react-meta-hooks

Quick Start

1. Wrap your app with MetaProvider

import React from 'react';
import { MetaProvider } from 'react-meta-hooks';
import App from './App';

const Root = () => (
  <MetaProvider>
    <App />
  </MetaProvider>
);

export default Root;

Detailed Examples

1. Basic Metadata (useTitle, useDescription)

Easily update the page title and description.

import { useTitle, useDescription } from 'react-meta-hooks';

const MyPage = () => {
  useTitle('Home Page | My App');
  useDescription('Welcome to my application where we manage metadata efficiently.');

  return <div>My Content</div>;
};

2. Social Media & SEO (useSocialMeta)

Generate Open Graph (og:) and Twitter (twitter:) tags with a single call.

import { useSocialMeta } from 'react-meta-hooks';

const ProductPage = () => {
  useSocialMeta({
    title: 'Awesome Product',
    description: 'The best developer tool in the market.',
    image: 'https://example.com/product.jpg',
    url: 'https://example.com/product',
    card: 'summary_large_image', // Optional Twitter card type
  });

  return <div>Product Details</div>;
};

3. Structured Data (useStructuredData)

Inject JSON-LD for rich search results.

import { useStructuredData } from 'react-meta-hooks';

const Article = () => {
  useStructuredData({
    "@context": "https://schema.org",
    "@type": "NewsArticle",
    "headline": "New advancement in React Meta Hooks",
    "datePublished": "2024-03-31",
    "author": {
      "@type": "Person",
      "name": "Satish"
    }
  });

  return <article>...</article>;
};

4. Link Tags (useLink)

Manage <link> tags like canonical URLs or favicons.

import { useLink } from 'react-meta-hooks';

const CanonicalPage = () => {
  useLink('canonical', 'https://example.com/canonical-url');
  useLink('icon', 'https://example.com/favicon.ico');

  return <div>Canonical Page</div>;
};

5. Custom Meta Tags (useMeta)

For any custom <meta> tags that aren't covered by specific hooks.

import { useMeta } from 'react-meta-hooks';

const CustomPage = () => {
  // Sets <meta name="theme-color" content="#ffffff">
  useMeta('theme-color', '#ffffff');
  
  // Sets <meta property="robots" content="noindex">
  useMeta('robots', 'noindex');

  return <div>Private Page</div>;
};

6. Server-Side Rendering (SSR)

MetaProvider can be initialized with tags for SSR support.

import { MetaProvider } from 'react-meta-hooks';

const serverInitTags = {
  title: 'Server Rendered Title',
  meta: { description: 'Server rendered description' },
  links: { canonical: 'https://example.com' },
  structuredData: []
};

function App() {
  return (
    <MetaProvider tags={serverInitTags}>
      {/* Your app components */}
    </MetaProvider>
  );
}

API Reference

| Hook | Parameters | Description | | --- | --- | --- | | useTitle | (title: string) | Set the browser tab title. | | useDescription | (description: string) | Set the SEO meta description. | | useLink | (rel: string, href: string) | Set a generic <link> tag (e.g., canonical). | | useMeta | (name: string, content: string) | Set a generic <meta> tag by name/property. | | useSocialMeta | (options: object) | Batch set Open Graph and Twitter tags. | | useStructuredData| (data: object) | Inject JSON-LD structured data script. |

Development Scripts

  • npm run build: Build for production (ESM, CJS, and types)
  • npm run test: Run all unit tests
  • npm run prepublishOnly: Runs build and tests securely before npm publish
  • npm run dev: Start building in watch mode

License

MIT