[GH-ISSUE #1717] Type incompatible for stripe plugin #8884

Closed
opened 2026-04-13 04:08:16 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @davidabou on GitHub (Mar 7, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1717

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a nuxt project
  2. Install and setup better-auth
  3. Install stripe and @better-auth/stripe version 1.2.4-beta.4
  4. Configure stripe plugin

Current vs. Expected behavior

Current
I have an error on the auth server part :

import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { PrismaClient } from '@prisma/client'
import { stripe } from '@better-auth/stripe'
import Stripe from 'stripe'

const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!)
export const prisma = new PrismaClient()

export const auth = betterAuth({
  baseURL: process.env.BETTER_AUTH_URL!,
  database: prismaAdapter(prisma, { provider: 'postgresql' }),
  emailAndPassword: { enabled: true },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID!,
      clientSecret: process.env.GITHUB_CLIENT_SECRET!
    }
  },
  user: {
    deleteUser: { enabled: true }
  },
  account: {
    accountLinking: { enabled: true, allowDifferentEmails: true }
  },
  plugins: [
    stripe({
    ^^^^^^^^
      stripeClient,
      ^^^^^^^^^^^^^
      stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      createCustomerOnSignUp: true,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      subscription: {
      ^^^^^^^^^^^^^^^
        enabled: true,
        ^^^^^^^^^^^^^^
        plans: [
        ^^^^^^^^
          {
          ^
            name: 'pro',
            ^^^^^^^^^^^^
            priceId: 'price_1234'
            ^^^^^^^^^^^^^^^^^^^^^
          }
          ^
        ]
        ^
      }
      ^
    })
    ^^
  ]
})
Type '{ id: "stripe"; endpoints: { stripeWebhook: { <C extends [({ body?: undefined; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<string, any> | undefined; request?: Request | undefined; headers?: HeadersInit | undefined; asResponse?: boolean | undefined; returnHeaders?: boolean | ...' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; name: string; email: string; emailVerified: boolean; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; }, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; secret?: string | undefined; secondaryStorage?: { get?: ((key: string) => string | ... 1 more ... | null) | undefined; set?: ((key: string, value: string, ttl?: number | undefined) => void | Promise<...>) | undefin...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.

And I have also an error on the betterAuth client config :

const client = createAuthClient({
    baseURL: url.origin,
    fetchOptions: { headers },
    plugins: [stripeClient({ subscription: true })]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  })
Type '{ id: "stripe-client"; $InferServerPlugin: { id: "stripe"; endpoints: { stripeWebhook: { <C extends [({ body?: undefined; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<string, any> | undefined; request?: Request | undefined; headers?: HeadersInit | undefined; asResponse?: bool...' is not assignable to type 'BetterAuthClientPlugin'.
  The types of '$InferServerPlugin.init' are incompatible between these types.
    Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; name: string; email: string; emailVerified: boolean; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; }, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { session?: { session?: { [x: string]: any; id?: string | undefined; createdAt?: { toString?: (() => string) | undefined; toDateString?: (() => string) | undefined; ... 41 more ...; [Symbol.toPrimitive]?: { ...; } | undefined; } | undefined; ... 5 more ...; userAgent?: string...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.

So I don't have stripe autocompletion like .subscription or other

Expected
No errors with stripe autocompletion.

What version of Better Auth are you using?

1.2.3

Provide environment information

- OS: Windows 11
- Browser: Firefox

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { PrismaClient } from '@prisma/client'
import { stripe } from '@better-auth/stripe'
import Stripe from 'stripe'

const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!)
export const prisma = new PrismaClient()

export const auth = betterAuth({
  baseURL: process.env.BETTER_AUTH_URL!,
  database: prismaAdapter(prisma, { provider: 'postgresql' }),
  emailAndPassword: { enabled: true },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID!,
      clientSecret: process.env.GITHUB_CLIENT_SECRET!
    }
  },
  user: {
    deleteUser: { enabled: true }
  },
  account: {
    accountLinking: { enabled: true, allowDifferentEmails: true }
  },
  plugins: [
    stripe({
      stripeClient,
      stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
      createCustomerOnSignUp: true,
      subscription: {
        enabled: true,
        plans: [
          {
            name: 'pro',
            priceId: 'price_1234'
          }
        ]
      }
    })
  ]
})

Additional context

No response

Originally created by @davidabou on GitHub (Mar 7, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1717 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a nuxt project 2. Install and setup `better-auth` 3. Install `stripe` and `@better-auth/stripe` version `1.2.4-beta.4` 4. Configure stripe plugin ### Current vs. Expected behavior **Current** I have an error on the auth server part : ```ts import { betterAuth } from 'better-auth' import { prismaAdapter } from 'better-auth/adapters/prisma' import { PrismaClient } from '@prisma/client' import { stripe } from '@better-auth/stripe' import Stripe from 'stripe' const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!) export const prisma = new PrismaClient() export const auth = betterAuth({ baseURL: process.env.BETTER_AUTH_URL!, database: prismaAdapter(prisma, { provider: 'postgresql' }), emailAndPassword: { enabled: true }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET! } }, user: { deleteUser: { enabled: true } }, account: { accountLinking: { enabled: true, allowDifferentEmails: true } }, plugins: [ stripe({ ^^^^^^^^ stripeClient, ^^^^^^^^^^^^^ stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ createCustomerOnSignUp: true, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ subscription: { ^^^^^^^^^^^^^^^ enabled: true, ^^^^^^^^^^^^^^ plans: [ ^^^^^^^^ { ^ name: 'pro', ^^^^^^^^^^^^ priceId: 'price_1234' ^^^^^^^^^^^^^^^^^^^^^ } ^ ] ^ } ^ }) ^^ ] }) ``` ``` Type '{ id: "stripe"; endpoints: { stripeWebhook: { <C extends [({ body?: undefined; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<string, any> | undefined; request?: Request | undefined; headers?: HeadersInit | undefined; asResponse?: boolean | undefined; returnHeaders?: boolean | ...' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; name: string; email: string; emailVerified: boolean; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; }, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; secret?: string | undefined; secondaryStorage?: { get?: ((key: string) => string | ... 1 more ... | null) | undefined; set?: ((key: string, value: string, ttl?: number | undefined) => void | Promise<...>) | undefin...'. Types of parameters 'ctx' and 'ctx' are incompatible. ``` And I have also an error on the betterAuth client config : ```ts const client = createAuthClient({ baseURL: url.origin, fetchOptions: { headers }, plugins: [stripeClient({ subscription: true })] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ }) ``` ``` Type '{ id: "stripe-client"; $InferServerPlugin: { id: "stripe"; endpoints: { stripeWebhook: { <C extends [({ body?: undefined; method?: "POST" | undefined; query?: Record<string, any> | undefined; params?: Record<string, any> | undefined; request?: Request | undefined; headers?: HeadersInit | undefined; asResponse?: bool...' is not assignable to type 'BetterAuthClientPlugin'. The types of '$InferServerPlugin.init' are incompatible between these types. Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; name: string; email: string; emailVerified: boolean; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; }, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { session?: { session?: { [x: string]: any; id?: string | undefined; createdAt?: { toString?: (() => string) | undefined; toDateString?: (() => string) | undefined; ... 41 more ...; [Symbol.toPrimitive]?: { ...; } | undefined; } | undefined; ... 5 more ...; userAgent?: string...'. Types of parameters 'ctx' and 'ctx' are incompatible. ``` So I don't have stripe autocompletion like `.subscription` or other **Expected** No errors with stripe autocompletion. ### What version of Better Auth are you using? 1.2.3 ### Provide environment information ```bash - OS: Windows 11 - Browser: Firefox ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth' import { prismaAdapter } from 'better-auth/adapters/prisma' import { PrismaClient } from '@prisma/client' import { stripe } from '@better-auth/stripe' import Stripe from 'stripe' const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!) export const prisma = new PrismaClient() export const auth = betterAuth({ baseURL: process.env.BETTER_AUTH_URL!, database: prismaAdapter(prisma, { provider: 'postgresql' }), emailAndPassword: { enabled: true }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET! } }, user: { deleteUser: { enabled: true } }, account: { accountLinking: { enabled: true, allowDifferentEmails: true } }, plugins: [ stripe({ stripeClient, stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, createCustomerOnSignUp: true, subscription: { enabled: true, plans: [ { name: 'pro', priceId: 'price_1234' } ] } }) ] }) ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:08:16 -05:00
Author
Owner

@michalzarsm commented on GitHub (Mar 11, 2025):

Same issue here.

EDIT:
Okay, actually i think i found a solution.

You need to ensure that "better-auth" and "@better-auth/stripe" are on the exact same versions.

Once i updated my "better-auth" version from 1.2.0 to 1.2.3 (same as the plugin) the problem disappeared.

Hope this helps.

<!-- gh-comment-id:2713832682 --> @michalzarsm commented on GitHub (Mar 11, 2025): Same issue here. EDIT: Okay, actually i think i found a solution. You need to ensure that "better-auth" and "@better-auth/stripe" are on the exact same versions. Once i updated my "better-auth" version from 1.2.0 to 1.2.3 (same as the plugin) the problem disappeared. Hope this helps.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8884