Skip to main content

@paymint/nextjs

Next.js SDK for Paymint - subscription billing made simple.

Installation

Quick Start

1. Create API Route

2. Add Provider

3. Use Hooks

4. Create Success Page

Imports

API Routes Created

The nextRouteHandler creates these endpoints automatically:

Hooks

useBilling()

useCheckout()

useSubscription()

Post-Checkout Success Handling

After a successful checkout, you have two options:

Option 1: Use onCheckoutComplete Callback

Option 2: Use Paddle’s successUrl

Fetching Latest Subscription on Success Page

Note: Subscriptions are created via Paddle webhooks. There may be a brief delay (1-5 seconds) between payment completion and subscription appearing in the database.

Server-Side Usage

Auth Integration

Clerk

NextAuth

Supabase

Security

Developer Responsibilities

The SDK handles most security concerns, but developers must ensure:

1. getCustomerEmail - Get Email from Auth Session (CRITICAL)

2. Keep API Key Server-Side Only

3. Use HTTPS in Production

Always deploy with HTTPS to protect session cookies.

What Paymint Handles

What Developers Must Handle

Environment Variables

The SDK auto-detects sandbox vs production from your API key:
  • paymint_test_xxx → Paddle Sandbox
  • paymint_live_xxx → Paddle Production
No need for NEXT_PUBLIC_PADDLE_ENVIRONMENT!

License

MIT