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

@contentcredits/sdk

v2.11.0

Published

Content Credits JS SDK — drop-in paywall and comments for any website

Readme

@contentcredits/sdk

npm version license TypeScript

Drop-in paywall and threaded comment system for any website. Add credit-based article monetisation in under 5 minutes — no backend changes required.

Full documentation →


What it does

  • Paywall — hides premium content behind a credit gate using a CSS selector. Reveals it instantly when the reader pays. No server-side content splitting needed.
  • Comments — threaded comment panel with likes, edit, delete, and sorting. Rendered in a Shadow DOM so it never conflicts with your CSS.
  • Auth — popup-based login on desktop, redirect flow on mobile. Tokens stored in memory (never cookies).
  • Extension support — detects the Content Credits Chrome extension for a one-click experience.

Installation

npm install @contentcredits/sdk

Or via CDN (no build step):

<script src="https://cdn.jsdelivr.net/npm/@contentcredits/[email protected]/dist/content-credits.umd.min.js"></script>

Quick start

Script tag (CDN)

<!-- Wrap your premium content -->
<div id="premium-content">
  <p>This content is only visible after the reader pays.</p>
</div>

<!-- Load and initialise the SDK -->
<script src="https://cdn.jsdelivr.net/npm/@contentcredits/[email protected]/dist/content-credits.umd.min.js"></script>
<script>
  ContentCreditsSDK.ContentCredits.init({
    apiKey: 'pub_YOUR_API_KEY',
    contentSelector: '#premium-content',
    teaserParagraphs: 2,
    enableComments: true,
  });
</script>

Auto-init (zero JavaScript)

<script
  src="https://cdn.jsdelivr.net/npm/@contentcredits/[email protected]/dist/content-credits.umd.min.js"
  data-api-key="pub_YOUR_API_KEY"
  data-content-selector="#premium-content"
  data-teaser-paragraphs="2"
></script>

npm / ES module

import { ContentCredits } from '@contentcredits/sdk';

const cc = ContentCredits.init({
  apiKey: 'pub_YOUR_API_KEY',
  contentSelector: '#premium-content',
  teaserParagraphs: 2,
  enableComments: true,
});

cc.on('paywall:hidden', () => {
  console.log('Article unlocked!');
});

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | required | Your publisher API key from the dashboard | | contentSelector | string | '.cc-premium-content' | CSS selector for the gated element | | teaserParagraphs | number | 2 | Paragraphs to show before the paywall | | enableComments | boolean | true | Show the comment widget | | articleUrl | string | location.href | Canonical URL of the article | | theme.primaryColor | string | '#44C678' | Brand colour for buttons | | theme.fontFamily | string | system UI | Font for all SDK UI | | onAccessGranted | () => void | — | Fires when content is unlocked | | debug | boolean | false | Verbose console logging |


Events

cc.on('ready',               ({ state }) => { });
cc.on('auth:login',          ({ user }) => { });
cc.on('auth:logout',         () => { });
cc.on('paywall:shown',       () => { });
cc.on('paywall:hidden',      () => { });
cc.on('article:purchased',   ({ creditsSpent, remainingBalance }) => { });
cc.on('credits:insufficient',({ required, available }) => { });
cc.on('comment:posted',      ({ comment }) => { });
cc.on('comment:liked',       ({ commentId, hasLiked }) => { });
cc.on('comment:deleted',     ({ commentId }) => { });
cc.on('error',               ({ message, error }) => { });

All events are also dispatched as native CustomEvents on document with the prefix contentcredits: — useful for Google Tag Manager and analytics integrations.


API

const cc = ContentCredits.init(config);

cc.on(event, handler)    // subscribe — returns unsubscribe fn
cc.off(event, handler)   // unsubscribe
cc.getState()            // → SDKState snapshot
cc.checkAccess()         // trigger access check manually
cc.openComments()        // open comment panel
cc.closeComments()       // close comment panel
cc.isLoggedIn()          // → boolean
cc.destroy()             // tear down SDK, restore hidden content

ContentCredits.version   // → "2.0.0"

React / Next.js

'use client'; // Next.js App Router

import { useEffect } from 'react';
import { ContentCredits } from '@contentcredits/sdk';

export function PremiumGate({ apiKey, children }) {
  useEffect(() => {
    const cc = ContentCredits.init({
      apiKey,
      contentSelector: '#premium-content',
    });
    return () => cc.destroy();
  }, [apiKey]);

  return <div id="premium-content">{children}</div>;
}

Requirements

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Your domain must be registered as a publisher at app.contentcredits.com
  • HTTPS required in production

Examples

| Example | Description | |---------|-------------| | examples/nextjs-blog | Next.js 14 (App Router) blog with free and premium articles — the fastest way to see the SDK in a real project |


Links