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

startsimpli-billing

v0.1.0

Published

Universal billing integration for StartSimpli Next.js apps

Downloads

203

Readme

@startsimpli/billing

Universal billing integration for StartSimpli Next.js apps. Products and pricing are configured in Django admin — frontend components auto-fetch and render.

Backend Setup

The billing backend lives in start-simpli-api/apps/billing/. Models, admin, and API are already configured.

Key Endpoints

| Endpoint | Method | Auth | Description | |----------|--------|------|-------------| | /api/v1/billing/products/ | GET | Public | List public products with offers | | /api/v1/billing/products/{slug}/ | GET | Public | Get product by slug | | /api/v1/billing/offer-checkout/ | POST | Required | Create checkout session | | /api/v1/billing/offer-portal/ | POST | Required | Create portal session | | /api/v1/billing/subscription/current/ | GET | Required | Get current user's subscription |

Admin Workflow

  1. Add a BillingProviderCredential (Stripe secret key + webhook secret)
  2. Create a BillingProduct (slug = identifier used by frontend)
  3. Add ProductOffer inlines (pricing tiers)
  4. Use "Sync to provider" admin action to push to Stripe

Frontend Setup

Installation

In your Next.js app's package.json:

{
  "dependencies": {
    "@startsimpli/billing": "workspace:*"
  }
}

Add transpilePackages: ['@startsimpli/billing'] to next.config.js.

Usage

import { BillingProvider, PricingPage, useCheckout, ManageSubscription } from '@startsimpli/billing'

// Wrap your app (or a subtree) with BillingProvider
<BillingProvider apiBaseUrl="/api/v1" authToken={accessToken}>
  <PricingPage productId="raise-simpli" onSelectOffer={handleSelect} />
</BillingProvider>

// Checkout hook
const { checkout, loading } = useCheckout()
await checkout({ offerId, successUrl, cancelUrl })

// Subscription management
<ManageSubscription returnUrl="/settings" buttonText="Manage Billing" />

Components

| Component | Props | Description | |-----------|-------|-------------| | BillingProvider | apiBaseUrl, authToken | Context provider — required wrapper | | PricingPage | productId, onSelectOffer? | Full pricing display with offer cards | | PricingSection | productId, onSelectOffer? | Pricing section component | | PricingDetailPage | productId, onSelectOffer? | Detailed pricing page | | UpgradeModal | productId, open, onClose, onSelectOffer? | Modal pricing overlay | | ManageSubscription | returnUrl, buttonText? | Portal redirect button | | SubscriptionManager | productId? | Full subscription management interface |

Hooks

| Hook | Returns | Description | |------|---------|-------------| | useProduct(slug) | { product, loading, error } | Fetch product + offers | | useCheckout() | { checkout, subscribeFree, loading, error } | Create checkout session or free subscription | | usePortal() | { openPortal, loading, error } | Open customer portal | | useSubscription() | { subscription, loading, error, refetch } | Get current user's subscription |

Architecture

  • Provider-agnostic: BaseBillingProviderStripeBillingProvider (extensible to Paddle, etc.)
  • BillingProviderFactory: Resolves credentials per-team with global fallback
  • BillingService: Orchestrates sync, checkout, and portal operations
  • ProductOffer: Supports flat, per_seat, tiered, volume, and usage pricing models

Integration with @startsimpli/auth

The billing package integrates seamlessly with @startsimpli/auth:

import { BillingProvider } from '@startsimpli/billing'
import { useAuth } from '@startsimpli/auth'

function App() {
  const { tokens } = useAuth()

  return (
    <BillingProvider
      apiBaseUrl={process.env.NEXT_PUBLIC_API_URL + '/api/v1'}
      authToken={tokens?.access}
    >
      {/* Your app */}
    </BillingProvider>
  )
}

Environment Variables

NEXT_PUBLIC_API_URL=https://api.startsimpli.com

Backend requires:

STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

Tests

# Frontend tests (39 tests)
cd packages/billing
npm test

# Backend tests (184 tests)
cd start-simpli-api
docker-compose -f docker-compose.local.yml exec -T django pytest apps/billing/tests/ -v

Development

# Type checking
npm run type-check

# Watch mode for tests
npm run test:watch

# Coverage report
npm run test:coverage