Introducing the Chargebee CLI

Next.js Adapter

The Chargebee Next.js adapter provides route handlers for integrating Chargebee Hosted Pages (checkout, payment methods, and customer portal) into Next.js App Router applications.

Prerequisites

  • Next.js 15 or later

Installation

Features

The adapter provides four route handler factories:

  • createSubscriptionCheckout — Redirects to a Chargebee subscription checkout page
  • createOneTimeCheckout — Redirects to a one-time charge checkout page
  • managePaymentSources — Redirects to the payment method management page
  • createPortalSession — Redirects to the Chargebee self-service portal

Each factory takes your credentials and returns an async (req: NextRequest) => NextResponse handler.

Setup

1. Configure Environment

Add your Chargebee credentials to .env.local:

2. Create Route Handlers

Subscription Checkout

One-Time Checkout

Customer Portal

Manage Payment Sources