October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Better Auth + Stripe in NestJS: Setup, Webhooks, and the Integration Seams

A practical map of the Better Auth–Stripe–NestJS integration: server setup, schema migration, NestJS adapter configuration, webhook events, and client plugin choices.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To wire Better Auth to Stripe in a NestJS app, configure the Better Auth Stripe plugin on your server-side auth instance, apply the plugin’s database schema, then expose that auth instance through the NestJS adapter @thallesp/nestjs-better-auth. For billing webhooks, Stripe must reach Better Auth’s webhook route with the original request body intact so signature verification can work. Add the Stripe client plugin only if your frontend needs its subscription-management APIs.

How the integration fits together

Better Auth owns the authentication and billing integration logic; Stripe processes payments and sends subscription events; NestJS connects requests to the Better Auth instance. These are related pieces, but each has a distinct job:

As an Amazon Associate I earn from qualifying purchases.

Piece Responsibility Where it belongs
Better Auth server instance Holds the auth configuration, database connection, and server plugins. Your server-side application setup.
Better Auth Stripe plugin Connects Better Auth to Stripe, manages subscription-related behavior, and verifies webhook signatures. The Better Auth server configuration.
@thallesp/nestjs-better-auth Connects the Better Auth instance to NestJS request handling. Your NestJS application module and bootstrap setup.
Stripe client plugin Enables the documented client-side subscription-management APIs. Frontend configuration, only when those APIs are needed.

Better Auth describes its NestJS integration as community maintained, rather than a built-in NestJS integration. Its guide also identifies Fastify support as beta, so check platform compatibility before relying on that combination. See the Better Auth NestJS integration guide.

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

How do I set up Stripe subscriptions with Better Auth?

Install the server packages

The documented setup uses the Better Auth Stripe plugin and Stripe’s server SDK:

npm install @better-auth/stripe stripe

If your server and frontend are installed as separate applications, install the Stripe plugin package in each application that uses it. The server package is needed for server configuration; the client import is separate and is covered below.

Configure the server-side auth instance

Add stripe() to the plugins on the Better Auth server instance. Provide it with a Stripe client and the webhook signing secret, and set createCustomerOnSignUp: true if you want the documented automatic customer-creation behavior. The plugin also supports subscription plan and pricing management, subscription lifecycle handling, trial support, and organization or team subscriptions. Choose only the features and settings your application needs; the exact plan and customer flows depend on your product configuration.

The Better Auth Stripe documentation’s example specifies Stripe SDK v22.0.0 and API version 2026-06-24.dahlia. Those are example values from that documentation, not a compatibility guarantee for every Better Auth, NestJS, or Stripe package combination. Confirm the versions supported by your project when implementing the configuration. See Better Auth’s Stripe plugin documentation.

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

Apply the plugin schema

The Stripe plugin adds database schema. Run Better Auth’s migration workflow when it is supported by your database setup, or generate the schema and apply it manually using your project’s migration process. The right route depends on the database adapter and existing schema workflow; do not assume installing the plugin alone updates the database. Better Auth describes its database and schema workflows in its installation documentation.

Connect the auth instance to NestJS

Use the adapter named by Better Auth’s integration guide, then register the same server-side auth instance with NestJS. The guide’s setup disables NestJS’s built-in body parser and imports the module with AuthModule.forRoot({ auth }):

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

These are the documented configuration points, not a complete NestJS application file: place them in the corresponding bootstrap and module-registration locations in your project. Disabling the built-in parser allows Better Auth to handle the raw request body, which matters for Stripe webhook signature verification.

The adapter guide says an AuthGuard is registered globally. It documents @AllowAnonymous() for routes that should be public, @OptionalAuth() when authentication is optional, and @Session() to access session data. Use the route exception that matches the endpoint’s access policy; consult the adapter’s linked repository from the integration guide for comprehensive decorator, hook, and advanced configuration details.

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

How do I receive Stripe webhooks in NestJS?

Point Stripe to Better Auth’s webhook endpoint

The plugin’s documented default URL is https://your-domain.com/api/auth/stripe/webhook. The default Better Auth base path is /api/auth; if your application changes that base path, configure Stripe to send events to the corresponding webhook route instead. Better Auth’s installation documentation describes the default auth handler path, and the Stripe plugin documentation specifies the webhook path.

Subscribe to the required Stripe events

Configure Stripe to send these events to that endpoint:

  • checkout.session.completed
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted

These are the events listed by the Better Auth plugin documentation for the integration. Store the Stripe webhook signing secret in the environment variable used by your Better Auth configuration; the plugin uses it to verify incoming signatures.

Preserve and verify the original request

Do not let NestJS or an upstream layer consume or transform the body before Better Auth processes the webhook. The adapter’s bodyParser: false instruction and the Stripe plugin’s signature verification together make raw-body handling an important boundary. Check your actual deployment path—including any proxy or platform adapter—to confirm the webhook reaches the handler with the original payload and that an invalid signature is rejected. The cited setup does not specify every proxy, adapter, or NestJS-version configuration, so verify those details in your own environment rather than assuming the bootstrap setting covers every deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should you add the Stripe client plugin?

The server-side Stripe plugin handles the billing integration and webhook processing. Add the frontend plugin only if the client needs the documented subscription-management APIs: import it from @better-auth/stripe/client and enable subscription: true in the client plugin configuration as shown in the Stripe documentation. A frontend subscription UI is a separate choice; it does not replace the server plugin, database schema, webhook route, or signing secret.

What to check before launch

  • Confirm the NestJS platform and versions you use are supported by your chosen adapter; the Better Auth guide specifically marks Fastify support as beta.
  • Confirm the Better Auth Stripe plugin’s schema is present in the database used by the application.
  • Verify Stripe is sending all four documented events to the correct public webhook URL.
  • Test that valid webhook signatures are accepted and invalid ones are rejected in the deployed request path.
  • Check how your application handles retries and duplicate event delivery, and how it reconciles subscription state if event processing fails. These are prudent implementation checks; the cited documentation does not provide a complete test runbook or prescribe a specific reconciliation design.
  • Confirm package compatibility for your exact NestJS, adapter, Better Auth, Stripe plugin, and Stripe SDK versions. The available integration pages do not provide a cross-package compatibility matrix.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.