Skip to main content

@creem_io/nextjs

The simplest way to integrate Creem payments into your Next.js application.

Build beautiful checkout experiences with React components, handle webhooks with ease, and manage subscriptions without the headache.


Introduction

@creem_io/nextjs is the official adapter for running Creem inside the Next.js App Router. It gives you:
  • 🎨 React Components — Drop-in checkout and portal components that wrap routing logic.
  • 🔐 Type-safe APIs — Full TypeScript coverage and sensible defaults.
  • Zero-config setup — Works with App Router filesystem routing.
  • 🪝 Webhook helpers — Automatic verification and strongly typed handlers.
  • 🔄 Subscription lifecycle — Built-in helpers for grant/revoke access flows.
Use it as your default integration path whenever you are building on Next.js. For other runtimes, you can still call the REST API or the TypeScript SDK directly, but this adapter keeps everything in one place.

Installation

Install the package with your favorite manager:

Requirements

  • Next.js 13+ using the App Router
  • React 18+
  • A Creem account with API keys

Quick Start

The adapter follows a four-step setup. The snippets below mirror what we use in production templates.

1. Configure environment variables

2. Create a checkout route

3. Drop the checkout component into your UI

4. Handle webhooks

Once these routes are in place you can test end-to-end by creating a checkout session, redirecting the user, and watching the webhook fire.

Components

<CreemCheckout />

Creates a checkout link and delegates session creation to your /checkout route handler.

<CreemPortal />

Generate a customer portal link for managing billing:

Server Functions

Checkout

Creates a GET route handler that issues checkout sessions.

Portal

Generate customer portal sessions from a server route:

Webhook

Verify webhooks and run lifecycle hooks:

Access Management

Leverage onGrantAccess and onRevokeAccess to keep your database in sync.

Best Practices

  • Use environment variables for API keys and webhook secrets.
  • Pass referenceId whenever possible to map users to Creem customers.
  • Test in testMode before switching the adapter to production.
  • Keep callbacks idempotent so multiple webhook event deliveries stay safe.

Resources

GitHub Repository

Star or contribute to the adapter on GitHub.

Creem Next.js Template

Full-stack example with Prisma, Better Auth, and Shadcn UI.

Better Auth Integration

Learn how to wire auth + billing in one flow.

Need help? Contact us or join the Discord community.