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

next-meta-debug

v1.0.0

Published

A development-only package for debugging Next.js page metadata in the browser console

Downloads

3

Readme

next-meta-debug

A development-only package for debugging Next.js page metadata in the browser console and with a visual interface.

Features

  • 🔍 Console Logging: Logs all page metadata to the browser console with organized, grouped output
  • 🎨 Visual Debugger: Beautiful Tailwind CSS-styled floating debug panel with tabbed interface
  • 🪝 React Hook: useMetaDebug hook for programmatic access to metadata
  • 📱 Comprehensive Coverage: Extracts meta tags, Open Graph, Twitter Cards, structured data, links, and scripts
  • 🌙 Dark Mode Support: Built-in dark mode support for the visual debugger
  • 📋 Copy to Clipboard: One-click copy of all metadata as JSON
  • 🚀 Zero Dependencies: No external APIs or services required
  • 🔧 Cross-Version Compatible: Works with Next.js 12+ and both Pages Router & App Router

Installation

npm install next-meta-debug
# or
yarn add next-meta-debug
# or
pnpm add next-meta-debug

Quick Start

1. Visual Debugger Component

Add the debug component to your layout or page:

import { MetaDebugComponent } from "next-meta-debug";

export default function Layout({ children }) {
  return (
    <html>
      <body>
        {children}
        {/* Only show in development */}
        {process.env.NODE_ENV === "development" && <MetaDebugComponent />}
      </body>
    </html>
  );
}

2. Console Logging

For console-only debugging:

import { extractPageMetadata, formatMetadataForConsole } from "next-meta-debug";

// In your component
useEffect(() => {
  if (typeof window !== "undefined") {
    const metadata = extractPageMetadata();
    formatMetadataForConsole(metadata);
  }
}, []);

3. React Hook

For programmatic access:

import { useMetaDebug } from "next-meta-debug";

function MyComponent() {
  const { metadata, title, description, logMetadata, toggleDebug } =
    useMetaDebug();

  return (
    <div>
      <h1>{title}</h1>
      <p>{description}</p>
      <button onClick={() => logMetadata()}>Log to Console</button>
      <button onClick={() => toggleDebug()}>Toggle Debug</button>
    </div>
  );
}

API Reference

MetaDebugComponent

A floating debug panel component with tabbed interface.

<MetaDebugComponent
  options={{
    enabled: true,
    logLevel: "info",
    includeStructuredData: true,
    includeScripts: true,
    includeLinks: true,
    groupByType: true,
    showTimestamp: true,
  }}
  showVisualDebugger={true}
  className="custom-class"
/>

Props:

  • options: DebugOptions configuration
  • showVisualDebugger: Whether to show the visual debugger (default: true)
  • className: Additional CSS classes

useMetaDebug Hook

Returns metadata and debug functions.

const {
  metadata, // Full metadata object
  isEnabled, // Whether debugging is enabled
  extractMetadata, // Function to extract metadata
  logMetadata, // Function to log to console
  toggleDebug, // Function to toggle debug state

  // Convenience properties
  title,
  description,
  keywords,
  author,
  robots,
  canonical,
  viewport,
  metaTags,
  openGraphTags,
  twitterTags,
  linkTags,
  scriptTags,
  structuredData,
} = useMetaDebug(options);

Utility Functions

extractPageMetadata()

Extracts all metadata from the current page DOM.

import { extractPageMetadata } from "next-meta-debug";

const metadata = extractPageMetadata();

formatMetadataForConsole(metadata, options)

Formats and logs metadata to the console with organized output.

import { formatMetadataForConsole } from "next-meta-debug";

formatMetadataForConsole(metadata, {
  groupByType: true,
  showTimestamp: true,
});

Metadata Types

The package extracts the following types of metadata:

  • Page Information: Title, description, keywords, author, robots, canonical URL, viewport
  • Meta Tags: All <meta> tags with name, property, http-equiv, and charset attributes
  • Open Graph Tags: All og:* properties for social media sharing
  • Twitter Card Tags: All twitter:* properties for Twitter sharing
  • Link Tags: All <link> tags including stylesheets, icons, and canonical URLs
  • Script Tags: All <script> tags with source URLs and inline content
  • Structured Data: JSON-LD structured data for SEO

Debug Options

interface DebugOptions {
  enabled?: boolean; // Enable/disable debugging
  logLevel?: "info" | "warn" | "error" | "debug"; // Console log level
  includeStructuredData?: boolean; // Include structured data in output
  includeScripts?: boolean; // Include script tags in output
  includeLinks?: boolean; // Include link tags in output
  groupByType?: boolean; // Group console output by metadata type
  showTimestamp?: boolean; // Show timestamp in console output
}

Visual Debugger Features

The visual debugger provides:

  • Floating Button: Fixed position debug button that expands into a panel
  • Tabbed Interface: Organized tabs for different metadata types
  • Responsive Design: Adapts to different screen sizes
  • Dark Mode: Automatic dark mode support
  • Copy to Clipboard: Export metadata as JSON
  • Console Integration: Direct console logging from the UI

Development vs Production

This package is designed for development use only. In production builds, the components and functions will still work but should be conditionally rendered:

{
  process.env.NODE_ENV === "development" && <MetaDebugComponent />;
}

Examples

Next.js App Router

// app/layout.tsx
import { MetaDebugComponent } from "next-meta-debug";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {children}
        {process.env.NODE_ENV === "development" && <MetaDebugComponent />}
      </body>
    </html>
  );
}

Next.js Pages Router

// pages/_app.tsx
import { MetaDebugComponent } from "next-meta-debug";

function MyApp({ Component, pageProps }) {
  return (
    <>
      <Component {...pageProps} />
      {process.env.NODE_ENV === "development" && <MetaDebugComponent />}
    </>
  );
}

export default MyApp;

Custom Debug Component

import { useMetaDebug } from "next-meta-debug";

function CustomDebugPanel() {
  const { metadata, logMetadata } = useMetaDebug({
    enabled: true,
    groupByType: true,
  });

  if (!metadata) return null;

  return (
    <div className="fixed top-4 right-4 bg-white p-4 rounded shadow-lg">
      <h3 className="font-bold mb-2">Page Metadata</h3>
      <div className="text-sm space-y-1">
        <div>
          <strong>Title:</strong> {metadata.title}
        </div>
        <div>
          <strong>Description:</strong> {metadata.description}
        </div>
        <div>
          <strong>Meta Tags:</strong> {metadata.meta.length}
        </div>
      </div>
      <button
        onClick={logMetadata}
        className="mt-2 px-3 py-1 bg-blue-500 text-white rounded text-xs"
      >
        Log to Console
      </button>
    </div>
  );
}

Compatibility

This package is designed to work with:

  • Next.js: 12.0.0 and above
  • React: 17.0.0 and above
  • React DOM: 17.0.0 and above
  • Node.js: 16.0.0 and above
  • Routing Systems: Both Pages Router and App Router
  • Browsers: Modern browsers with ES2017+ support

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Sushant R. Dangal - @srdarkseer

Support

If you have any questions or need help, please open an issue on GitHub.