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

mechapay-react

v0.1.15

Published

Mecha Pay React SDK for building high-performance subscription interfaces.

Downloads

17

Readme

mechapay-react

The professional, high-fidelity React SDK for the Mecha Protocol. Build stunning, production-ready subscription interfaces with custom-tailored styling, real-time blockchain synchronization, and zero third-party animation overhead.

🚀 Features

  • Provider Pattern: Centralized API key management with MechaProvider.
  • Live Hooks: Real-time membership tracking with useMecha.
  • Perk-Gated Interfaces: Resolve bought tier names, active features, and local expiration dates with useMechaPerks.
  • Smart Transitions: Automatic Contextual upgrade/downgrade button states based on prices (no rigid plan lockouts).
  • Double-Subscription Block: Blocks double-purchases of the same tier at the UI level.
  • Extreme Customizability: Inject custom button labels, style custom classes (classNames), and replace rendering completely using custom slot renderers (renderHeader, renderFooter, renderTierButton).
  • Performance First: Zero dependencies on heavy libraries like framer-motion. Built entirely using native, high-performance CSS hardware transitions.

📦 Installation

npm install mechapay-react

🛠️ Quick Start

1. Wrap your Application

import { MechaProvider } from 'mechapay-react';

function App() {
  return (
    <MechaProvider apiKey="mp_live_your_api_key_here">
      <MyRoutes />
    </MechaProvider>
  );
}

2. Add the Pricing Table

import { MechaPricingTable } from 'mechapay-react';

function PricingPage() {
  return (
    <MechaPricingTable 
      planId="0x..." 
      userId="user_123" 
      appearance={{
        theme: "dark",
        variables: {
          colorPrimary: "#00FFC2",
          borderRadius: "24px"
        }
      }}
    />
  );
}

🛡️ Hooks & Feature Gating

useMecha (Active Status & Countdown)

The primary hook to inspect the overall membership status, remaining time, and list of all active/bought tier IDs.

import { useMecha } from 'mechapay-react';

function PremiumFeature() {
  const { status, remainingSeconds, tierIds, loading } = useMecha(PLAN_ID, USER_ID);

  if (loading) return <div>Syncing status...</div>;
  if (status !== 'ACTIVE') return <div>Access Denied</div>;

  return (
    <div>
      <p>Premium Content Unlocked!</p>
      <p>Access ends in {Math.floor(remainingSeconds / 3600)} hours.</p>
    </div>
  );
}

useMechaPerks (Subscribed Perks & Features)

Fetches active plan details, listing subscribed tiers, their respective features, and custom expiration dates.

import { useMechaPerks } from 'mechapay-react';

function ActiveUserPerks() {
  const { perks, loading } = useMechaPerks(PLAN_ID, USER_ID);

  if (loading) return <div>Syncing perks...</div>;
  if (!perks) return <div>No active plans or perks.</div>;

  return (
    <div>
      <h3>Your Active Subscriptions & Perks</h3>
      {perks.map((subbedTier) => (
        <div key={subbedTier.tierId} style={{ marginTop: '16px' }}>
          <h4>{subbedTier.tierName} (Expires: {subbedTier.expiryDate.toLocaleDateString()})</h4>
          <ul>
            {subbedTier.features.map((feat, idx) => (
              <li key={idx}>
                <strong>{feat.title}</strong>: {feat.description}
              </li>
            ))}
          </ul>
        </div>
      ))}
    </div>
  );
}

🎨 Advanced Customization

1. Custom Labels (customLabels)

Override the default CTA texts easily:

<MechaPricingTable 
  planId="0x..." 
  userId="user_123"
  customLabels={{
    activeSubscription: "Current active tier",
    upgrade: "Level Up",
    downgrade: "Downgrade Plan",
    getTier: "Join {{tierLabel}}"
  }}
/>

2. Style Custom Class Overrides (classNames)

Map your own tailwind classes or custom stylesheets to specific components inside the pricing table:

<MechaPricingTable 
  planId="0x..." 
  userId="user_123"
  classNames={{
    card: "border-2 border-slate-700 bg-slate-900 rounded-3xl",
    button: "bg-emerald-500 text-slate-950 font-bold hover:scale-105"
  }}
/>

3. Slot Renderers (renderHeader, renderFooter, renderTierButton)

Replace specific sections of the layout completely while preserving internal loading states and purchase mechanics.

<MechaPricingTable 
  planId="0x..." 
  userId="user_123"
  renderTierButton={(tier, state, handleSelect) => (
    <button 
      onClick={handleSelect}
      disabled={state.isDisabled}
      className={`btn-${state.isUpgrade ? 'upgrade' : 'purchase'}`}
    >
      {state.label}
    </button>
  )}
/>

📄 License

MIT © Mecha Pay