Skip to main content
Billing SDK is a comprehensive open-source solution that provides complete billing infrastructure for modern web applications. It includes React components, CLI tooling, and full-stack integration support for multiple frameworks with Dodo Payments.

Overview

Billing SDK offers:
  • React Components: Pre-built, customizable billing components for React applications
  • CLI Tooling: Command-line interface for project initialization and component management
  • Framework Support: Integration with Next.js, Express.js, Hono, Fastify, and React
  • Payment Provider: Full integration with Dodo Payments

Quick Start

Get started with Billing SDK in minutes:
1

Install the CLI

Use npx to run the CLI without installation:
npx @billingsdk/cli --help
Or install it globally for frequent use:
npm install -g @billingsdk/cli
2

Initialize a Project

Run the interactive setup to create a new billing project:
npx @billingsdk/cli init
You’ll be prompted to select:
  • Your preferred framework (Next.js, Express.js, Hono, Fastify, React)
  • Your payment provider (Dodo Payments)
3

Add Components

Add individual billing components to your project:
npx @billingsdk/cli add pricing-table-one
npx @billingsdk/cli add subscription-management

Supported Frameworks

Billing SDK supports multiple frameworks with comprehensive Dodo Payments integration:
FrameworkDodo Payments
Next.js✅ Yes
Express.js✅ Yes
Hono✅ Yes
React✅ Yes
Fastify✅ Yes

CLI Commands

@billingsdk/cli init

Initialize a new billing project with complete setup including framework configuration, Dodo Payments integration, and essential dependencies. What it does:
  1. Framework Selection: Choose your preferred framework
  2. Template Installation: Downloads and installs framework-specific templates with Dodo Payments integration
  3. Dependency Management: Automatically installs required dependencies
  4. File Generation: Creates necessary configuration files and boilerplate code
Example:
npx @billingsdk/cli init

@billingsdk/cli add

Add individual billing components to your existing project using the shadcn/ui registry system. Examples:
# Add a pricing table
npx @billingsdk/cli add pricing-table-one

# Add subscription management
npx @billingsdk/cli add subscription-management

# Add usage monitoring
npx @billingsdk/cli add usage-meter-circle
What happens:
  1. Downloads the component configuration from the registry
  2. Installs the component files in your components/billingsdk/ directory
  3. Updates your project configuration if needed
  4. Installs any additional dependencies

Generated Files Structure

After running init, you’ll get a complete project structure with:
  • API Routes: Comprehensive endpoints for checkout, customers, products, subscriptions, and webhooks
  • Hooks: React hooks for billing operations (if using React/Next.js)
  • Library Files: Payment provider client initialization and utilities
  • Environment Configuration: Example environment variable files

Next.js Example Structure

your-project/
├── app/api/
│   └── (dodopayments)/
│       ├── checkout/route.ts
│       ├── customer/route.ts
│       ├── customer/payments/route.ts
│       ├── customer/subscriptions/route.ts
│       ├── product/route.ts
│       ├── products/route.ts
│       └── webhook/route.ts
├── hooks/
│   └── useBilling.ts
├── lib/
│   └── dodopayments.ts
└── .env.example

Environment Configuration

Configure your environment variables after initialization:
# DodoPayments
DODO_PAYMENTS_API_KEY=your_api_key_here
DODO_PAYMENTS_ENVIRONMENT=test_mode
DODO_PAYMENTS_WEBHOOK_KEY=your_webhook_key_here

# App URL
NEXT_PUBLIC_APP_URL=http://localhost:3000
Always store your API keys securely using environment variables. Never commit them to version control.

Available Components

Billing SDK provides a comprehensive collection of React components:
  • Pricing Tables: Multiple variants for displaying product pricing
  • Subscription Management: Components for managing customer subscriptions
  • Usage Monitoring: Visual components for tracking usage-based billing
  • Checkout Components: Pre-built checkout flows
  • Customer Portal: Components for customer self-service

Open Source

Billing SDK is built on open-source principles:
  • 🔍 Transparency: Full visibility into how components work
  • 🤝 Community: Built by developers, for developers
  • 🔒 Security: Open code means better security through peer review
  • 📈 Innovation: Faster iteration through community contributions
Billing SDK is released under the GNU General Public License (GPL), ensuring the project remains open and free.

Getting Help

Need assistance with Billing SDK?

Contributing

We welcome contributions! See our contribution guide for details on:
  • Reporting bugs
  • Requesting features
  • Submitting pull requests
  • Adding new components
  • Improving documentation

Learn More