# Next.js Adapter[](#nextjs-adapter)

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


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[](#prerequisites)

-   Next.js 15 or later

## Installation[](#installation)

**npm**

```bash
npm install @chargebee/nextjs
```

**pnpm**

```bash
pnpm add @chargebee/nextjs
```

**yarn**

```bash
yarn add @chargebee/nextjs
```

## Features[](#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[](#setup)

### 1\. Configure Environment[](#1-configure-environment)

Add your Chargebee credentials to `.env.local`:

### 2\. Create Route Handlers[](#2-create-route-handlers)

#### Subscription Checkout[](#subscription-checkout)

#### One-Time Checkout[](#one-time-checkout)

#### Customer Portal[](#customer-portal)

#### Manage Payment Sources[](#manage-payment-sources)

## Links[](#links)

-   [GitHub Repository](https://github.com/chargebee/js-framework-adapters)
-   [Node.js SDK](/docs/sdks/nodejs)
-   [API Reference](/docs/api/getting-started)