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

@nozle-js/react

v0.5.0

Published

React SDK for usage-based billing. Hooks and components for entitlements, real-time usage tracking, plan management, and Stripe checkout.

Readme

@nozle-js/react

React SDK for usage-based billing. Hooks and components for entitlements, real-time usage tracking, plan management, and Stripe checkout.

Install

npm install @nozle-js/react

Peer dependencies:

npm install react react-dom @stripe/stripe-js @stripe/react-stripe-js

Quick Start

Wrap your app with BillingProvider:

import { BillingProvider } from "@nozle-js/react";

function App() {
  return (
    <BillingProvider
      apiKey="pk_live_..."
      customerId="cust_123"
      baseUrl="https://your-api.example.com"
      wsUrl="wss://your-ws.example.com/connection/websocket"
      stripeKey="pk_test_..."
      features={["tokens_used", "code_completions"]}
    >
      <YourApp />
    </BillingProvider>
  );
}

Hooks

useCan(feature)

Check if a customer has access to a feature.

import { useCan } from "@nozle-js/react";

function MyFeature() {
  const { allowed, isLoading, error } = useCan("advanced_analytics");

  if (isLoading) return <p>Loading...</p>;
  if (!allowed) return <p>Upgrade to access this feature.</p>;

  return <div>Feature content here</div>;
}

useUsage(metric)

Get real-time usage data for a metric. Updates automatically via WebSocket.

import { useUsage } from "@nozle-js/react";

function TokenCounter() {
  const { data, isLoading } = useUsage("tokens_used");

  if (isLoading || !data) return null;

  return (
    <p>
      {data.used.toLocaleString()} / {data.limit.toLocaleString()} tokens used
    </p>
  );
}

usePlan()

Get the customer's current plan and subscription status.

import { usePlan } from "@nozle-js/react";

function CurrentPlan() {
  const { data } = usePlan();

  if (!data) return null;

  return (
    <p>
      Plan: {data.plan_slug} ({data.subscription_status})
    </p>
  );
}

usePlans()

Fetch all available plans.

import { usePlans } from "@nozle-js/react";

function PlanList() {
  const { plans, isLoading } = usePlans();

  if (isLoading) return <p>Loading plans...</p>;

  return (
    <ul>
      {plans.map((plan) => (
        <li key={plan.code}>
          {plan.name} — ${(plan.amount_cents / 100).toFixed(2)}/{plan.interval}
        </li>
      ))}
    </ul>
  );
}

useCheckout()

Create a Stripe checkout session and render embedded checkout.

import { useCheckout } from "@nozle-js/react";

function UpgradeButton({ planCode }: { planCode: string }) {
  const { fetchClientSecret, isLoading } = useCheckout();

  const handleUpgrade = async () => {
    const clientSecret = await fetchClientSecret(planCode);
    // Use clientSecret with Stripe EmbeddedCheckout
  };

  return (
    <button onClick={handleUpgrade} disabled={isLoading}>
      Upgrade
    </button>
  );
}

useSubscribe()

Create a subscription after successful payment.

import { useSubscribe } from "@nozle-js/react";

function AfterPayment({ planCode }: { planCode: string }) {
  const { subscribe, isLoading } = useSubscribe();

  const handleComplete = async () => {
    await subscribe(planCode);
  };

  return (
    <button onClick={handleComplete} disabled={isLoading}>
      Activate Subscription
    </button>
  );
}

Components

Pre-built UI components with built-in styling. No CSS imports needed.

UsageMeter

Displays usage with bar, ring, or minimal variants.

import { UsageMeter } from "@nozle-js/react";

<UsageMeter metric="tokens_used" variant="bar" />
<UsageMeter metric="tokens_used" variant="ring" />
<UsageMeter metric="tokens_used" variant="minimal" />

PlanBadge

Shows the current plan with status indicator.

import { PlanBadge } from "@nozle-js/react";

<PlanBadge variant="pill" />
<PlanBadge variant="text" />
<PlanBadge variant="icon" />

UpgradePrompt

Conditionally renders an upgrade prompt when a feature is gated.

import { UpgradePrompt } from "@nozle-js/react";

<UpgradePrompt feature="advanced_analytics" variant="card" upgradeUrl="/upgrade" />
<UpgradePrompt feature="advanced_analytics" variant="banner" />
<UpgradePrompt feature="advanced_analytics" variant="inline" />

Tailwind CSS Preset

Optional Tailwind preset for styling the data-nozle attributes on components.

// tailwind.config.ts
import { nozlePreset } from "@nozle-js/react/styles/preset";

export default {
  presets: [nozlePreset],
};

TypeScript

All hooks and components are fully typed. Exported types:

import type {
  BillingState,
  UseCanResult,
  UseUsageResult,
  UsePlanResult,
  UseCheckoutResult,
  Plan,
  UsageMeterProps,
  PlanBadgeProps,
  UpgradePromptProps,
} from "@nozle-js/react";

License

Proprietary