Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Run Better Auth’s Stripe plugin inside your Better Auth server instance, then expose that instance through the NestJS adapter. The critical integration seam is request-body handling: the adapter guide says to disable NestJS’s built-in body parser so Better Auth can receive the raw body needed for webhook signature verification. You will also need the plugin’s database schema and a Stripe webhook endpoint configured for the documented subscription events.

How the integration fits together

Better Auth owns authentication and the Stripe plugin’s billing behavior; NestJS hosts the Better Auth integration through the community-maintained @thallesp/nestjs-better-auth adapter. Stripe sends checkout and subscription events to the plugin’s webhook route, where the plugin verifies signatures and processes subscription lifecycle changes. The Better Auth Stripe documentation describes the plugin features, configuration, schema, and webhook setup.

The setup has four parts: configure Better Auth with a database and Stripe plugin, add the plugin’s schema to that database, register the Better Auth instance in NestJS, and configure Stripe to deliver events to the Better Auth webhook URL. A client-side Stripe plugin is an optional fifth part, needed only if the frontend uses its subscription-management client APIs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Configure Better Auth and the Stripe server plugin

Install @better-auth/stripe and Stripe’s server SDK in the server application. The Stripe plugin documentation’s example uses Stripe SDK v22.0.0 and API version 2026-06-24.dahlia; those are example values from the documentation, not a compatibility guarantee for every Better Auth, NestJS, or adapter version. Confirm the versions supported by your project when implementing.

Configure the Stripe plugin on the Better Auth server instance. This abbreviated example shows the documented integration points; keep your existing Better Auth database and other required configuration in the same instance:

import Stripe from "stripe";
import { betterAuth } from "better-auth";
import { stripe } from "@better-auth/stripe";

const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!);

export const auth = betterAuth({
  database: /* your Better Auth database configuration */,
  plugins: [
    stripe({
      stripeClient,
      webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
      createCustomerOnSignUp: true,
    }),
  ],
});

Use the exact option names and any additional configuration required by the Stripe plugin version installed in your application. Keep both Stripe secrets on the server; do not expose them to browser code. With createCustomerOnSignUp: true, the plugin is configured to create Stripe customers when users sign up. The Better Auth installation guide covers configuring the auth instance and database.

2. Add the Stripe plugin schema to the database

The Stripe plugin adds database schema. Apply it before relying on subscription or customer records: use Better Auth’s migration workflow when it is supported by your setup, or generate the schema and apply it through your project’s database migration process. The appropriate method depends on your database adapter and existing migration workflow; do not assume that installing the plugin alone creates the required tables or fields. See the Stripe plugin schema instructions and Better Auth installation guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Register Better Auth with NestJS

Install and configure @thallesp/nestjs-better-auth as described in Better Auth’s NestJS integration guide. In the Nest application bootstrap, disable NestJS’s built-in body parser, then import the adapter module with the same Better Auth instance that has the Stripe plugin configured:

const app = await NestFactory.create(AppModule, {
  bodyParser: false,
});
AuthModule.forRoot({ auth })

These are the key documented setup points rather than a complete NestJS application: place the bootstrap option in your existing NestFactory.create call and register AuthModule.forRoot({ auth }) in the module setup required by the adapter. The adapter guide describes a global AuthGuard; use @AllowAnonymous() on routes that should be public and @OptionalAuth() where authentication is optional. Its @Session() decorator provides session access. The guide identifies the adapter as community maintained and says Fastify support is beta, so verify platform compatibility and consult the adapter’s repository for detailed configuration.

4. Point Stripe webhooks at Better Auth

With Better Auth’s default base path, the Stripe plugin’s default webhook URL is https://your-domain.com/api/auth/stripe/webhook. Replace the example host with the public HTTPS URL for your deployment. Better Auth’s general installation documentation describes the default auth handler path as /api/auth/*; the Stripe plugin places its webhook route beneath that path.

Configure Stripe to send at least these events to the endpoint:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • checkout.session.completed
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted

Set the webhook signing secret issued for that endpoint as the value supplied to the plugin’s webhookSecret configuration. Use the secret for the endpoint and environment receiving the events; a test-mode endpoint and a live-mode endpoint have different configuration contexts. The plugin documents webhook signature verification, but your deployment still needs to deliver the original request payload to the handler.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Keep raw-body handling intact

Webhook signature verification depends on the original request body. The NestJS adapter guide’s bodyParser: false setting allows Better Auth to handle the raw request body rather than receiving a body already parsed by NestJS. Middleware, reverse proxies, or other layers in your own deployment can still affect what reaches the route, so verify the behavior end to end for your NestJS platform and hosting setup. Confirm that valid Stripe deliveries are accepted and that a request with an invalid signature is rejected; the documentation does not provide a complete proxy- or platform-specific recipe.

6. Add client-side subscription APIs only if needed

The Stripe server plugin and webhook configuration do not by themselves require the Stripe client plugin. If your frontend needs the plugin’s subscription-management client APIs, install the package on the client side as well when server and client dependencies are separate, then import from @better-auth/stripe/client and enable subscription support as shown in the plugin documentation:

import { stripeClient } from "@better-auth/stripe/client";

// Include in the Better Auth client plugins configuration:
stripeClient({
  subscription: true,
})

Keep client-side subscription UI concerns separate from server-side webhook processing: the backend plugin, schema, signing secret, and Stripe event delivery are still needed for the server integration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verification checklist

  • Better Auth starts with the intended database and the Stripe plugin on its server instance.
  • The Stripe plugin schema has been applied through the project’s supported migration or schema workflow.
  • NestJS imports the adapter with that same auth instance, and built-in body parsing is disabled as documented.
  • The configured Stripe endpoint uses the intended public URL and receives the required checkout and subscription events.
  • The webhook signing secret matches the endpoint, valid signatures are accepted, and invalid signatures are rejected.
  • If using Fastify, compatibility has been checked against the adapter’s current beta support and the versions in the application.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.