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

@rironib/adsense

v1.0.0

Published

A lightweight, type-safe Google AdSense component for React and Next.js applications.

Readme

@rironib/adsense

A lightweight, type-safe, and optimized Google AdSense integration for React and Next.js (App Router).

🚀 Features

  • Next.js Optimized: Built specifically for the Next.js App Router using next/script.
  • Provider Pattern: Set your Publisher ID once at the root and use <Ads /> anywhere.
  • Environment Support: Automatically detects NEXT_PUBLIC_ADSENSE_PUBLISHER_ID.
  • Auto-Initialization: Manages adsbygoogle.push({}) automatically.
  • Type-Safe: Full TypeScript support for all AdSense data attributes.
  • Auto Ads Support: Enabling the provider is enough to support Auto Ads.

📦 Installation

npm install @rironib/adsense
# or
yarn add @rironib/adsense
# or
pnpm add @rironib/adsense

🛠️ Setup

1. Environment Variable (Recommended)

Add your Publisher ID to your .env.local file:

NEXT_PUBLIC_ADSENSE_PUBLISHER_ID=ca-pub-2274017621360737

2. Add the Provider

Wrap your application in the root layout (app/layout.tsx).

import { AdSenseProvider } from "@rironib/adsense";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {/* pId is optional if NEXT_PUBLIC_ADSENSE_PUBLISHER_ID is set */}
        <AdSenseProvider>{children}</AdSenseProvider>
      </body>
    </html>
  );
}

📖 Usage

Display Ads

Convert your standard AdSense snippet into a clean React component.

Standard Snippet:

<ins
  class="adsbygoogle"
  style="display:block"
  data-ad-client="ca-pub-2274017621360737"
  data-ad-slot="6292120180"
  data-ad-format="auto"
  data-full-width-responsive="true"
></ins>

React Component:

import { Ads } from "@rironib/adsense";

const Sidebar = () => (
  <Ads
    slot="6292120180"
    style={{ display: "block" }}
    format="auto"
    responsive={true}
  />
);

In-Feed & In-Article Ads

Pass specific attributes like layoutKey or layout as props.

<Ads
  slot="6292120180"
  format="fluid"
  layoutKey="-gw-e+1f-3d-2z"
  style={{ display: "block" }}
/>

⚙️ API Reference

AdSenseProvider

| Prop | Type | Default | Description | | ---------- | ----------- | ---------------- | --------------------------------- | | pId | string | process.env... | Your Google AdSense Publisher ID. | | children | ReactNode | - | Your application content. |

Ads

| Prop | Type | Default | Description | | ------------ | ------------------- | ---------------------- | ----------------------------------------------- | | slot | string | Required | The ad unit ID from your dashboard. | | format | string | 'auto' | Ad format ('auto', 'fluid', 'rectangle'). | | responsive | boolean \| string | 'true' | Enable/Disable responsive layout. | | layout | string | - | Used for specific ad types (e.g., In-article). | | layoutKey | string | - | Used for In-feed ads. | | style | CSSProperties | { display: 'block' } | Container styles. | | className | string | - | CSS class for the ins element. |

📝 License

MIT © rironib