[GH-ISSUE #1974] Expo plugin is not assignable to type 'BetterAuthPlugin' #26314

Closed
opened 2026-04-17 16:49:00 -05:00 by GiteaMirror · 39 comments
Owner

Originally created by @Nikola-Milovic on GitHub (Mar 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1974

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Following the guide for expo integration, there is a type error

import { serve } from '@hono/node-server'
import { Hono } from 'hono'

const app = new Hono()

import { betterAuth } from "better-auth";
import Database from "better-sqlite3";
import { expo } from '@better-auth/expo';

export const auth = betterAuth({
	database: new Database("./sqlite.db"),
	plugins: [
		expo()
	],
})

app.get('/', (c) => {
	return c.text('Hello Hono!')
})

serve({
	fetch: app.fetch,
	port: 3000
}, (info) => {
	console.log(`Server is running on http://localhost:${info.port}`)
})
Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.     
  Types of property 'init' are incompatible.                                                                                                                                                                                                                  
    Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] |      
    undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'.                                                                         
      Types of parameters 'ctx' and 'ctx' are incompatible.                                                                                                                                                                                                   
        Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.6BOIvSei", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.BaiNTuNz").l'.    
          The types of 'options.database' are incompatible between these types.                                                                                                                                                                               
            Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/    
            mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config").        
            PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'.                                                                                                     
              Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'.             
                Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'.          
                  The types of 'createAdapter().acquireMigrationLock' are incompatible between these types.                                                                                                                                                   
                    Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution-   
                    mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/     
                    dialect-adapter").MigrationLockOptions) => Promise<...>'.                                                                                                                                                                                 
                      Types of parameters 'db' and 'db' are incompatible.                                                                                                                                                                                     
                        Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'.            
                          Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. [2322

Current vs. Expected behavior

Would expect all the types to work properly

What version of Better Auth are you using?

1.2.4

Provide environment information

@better-auth/expo ^1.2.4

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

Types

Auth config (if applicable)


Additional context

I created a fresh project and there is still an error.

npm create hono@latest my-app 
npm install better-auth  @better-auth/expo better-sqlite3
npm i --save-dev @types/better-sqlite3
Originally created by @Nikola-Milovic on GitHub (Mar 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1974 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Following the guide for [expo](https://www.better-auth.com/docs/integrations/expo) integration, there is a type error ``` import { serve } from '@hono/node-server' import { Hono } from 'hono' const app = new Hono() import { betterAuth } from "better-auth"; import Database from "better-sqlite3"; import { expo } from '@better-auth/expo'; export const auth = betterAuth({ database: new Database("./sqlite.db"), plugins: [ expo() ], }) app.get('/', (c) => { return c.text('Hello Hono!') }) serve({ fetch: app.fetch, port: 3000 }, (info) => { console.log(`Server is running on http://localhost:${info.port}`) }) ``` ``` Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] | undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'. Types of parameters 'ctx' and 'ctx' are incompatible. Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.6BOIvSei", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.BaiNTuNz").l'. The types of 'options.database' are incompatible between these types. Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/ mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config"). PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'. Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'. Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'. The types of 'createAdapter().acquireMigrationLock' are incompatible between these types. Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution- mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/ dialect-adapter").MigrationLockOptions) => Promise<...>'. Types of parameters 'db' and 'db' are incompatible. Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'. Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. [2322 ``` ### Current vs. Expected behavior Would expect all the types to work properly ### What version of Better Auth are you using? 1.2.4 ### Provide environment information ```bash @better-auth/expo ^1.2.4 ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript ``` ### Additional context I created a fresh project and there is still an error. ``` npm create hono@latest my-app npm install better-auth @better-auth/expo better-sqlite3 npm i --save-dev @types/better-sqlite3 ```
GiteaMirror added the lockedbug labels 2026-04-17 16:49:00 -05:00
Author
Owner

@Bekacru commented on GitHub (Mar 24, 2025):

make sure both of packages @better-auth/expo and better-auth are on the latest. If it's still not fixed try @beta (i.e. pnpm i better-auth@beta)

<!-- gh-comment-id:2747840682 --> @Bekacru commented on GitHub (Mar 24, 2025): make sure both of packages `@better-auth/expo` and `better-auth` are on the latest. If it's still not fixed try `@beta` (i.e. pnpm i better-auth@beta)
Author
Owner

@moshetanzer commented on GitHub (Mar 25, 2025):

Hey @Nikola-Milovic,

make sure both of packages @better-auth/expo and better-auth are on the latest. If it's still not fixed try @beta (i.e. pnpm i better-auth@beta)

Did the above comment solve your issue?

<!-- gh-comment-id:2752606810 --> @moshetanzer commented on GitHub (Mar 25, 2025): Hey @Nikola-Milovic, > make sure both of packages `@better-auth/expo` and `better-auth` are on the latest. If it's still not fixed try `@beta` (i.e. pnpm i better-auth@beta) Did the above comment solve your issue?
Author
Owner

@Nikola-Milovic commented on GitHub (Mar 26, 2025):

No, if we use my reproduction example from above and use the @beta versions, it still fails

{
  "name": "my-app",
  "type": "module",
  "scripts": {
    "dev": "tsx watch src/index.ts"
  },
  "dependencies": {
    "@better-auth/expo": "^1.2.5-beta.10",
    "@hono/node-server": "^1.14.0",
    "better-auth": "^1.2.5-beta.10",
    "better-sqlite3": "^11.9.1",
    "hono": "^4.7.5"
  },
  "devDependencies": {
    "@types/better-sqlite3": "^7.6.12",
    "@types/node": "^20.11.17",
    "tsx": "^4.7.1"
  }
}
Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.     
  Types of property 'init' are incompatible.                                                                                                                                                                                                                  
    Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] |      
    undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'.                                                                         
      Types of parameters 'ctx' and 'ctx' are incompatible.                                                                                                                                                                                                   
        Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.DVddfEHH", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.aaUJqbx0").l'.    
          The types of 'options.database' are incompatible between these types.                                                                                                                                                                               
            Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/    
            mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config").        
            PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'.                                                                                                     
              Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'.             
                Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'.          
                  The types of 'createAdapter().acquireMigrationLock' are incompatible between these types.                                                                                                                                                   
                    Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution-   
                    mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/     
                    dialect-adapter").MigrationLockOptions) => Promise<...>'.                                                                                                                                                                                 
                      Types of parameters 'db' and 'db' are incompatible.                                                                                                                                                                                     
                        Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'.            
                          Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. 
<!-- gh-comment-id:2754580190 --> @Nikola-Milovic commented on GitHub (Mar 26, 2025): No, if we use my reproduction example from above and use the `@beta` versions, it still fails ```json { "name": "my-app", "type": "module", "scripts": { "dev": "tsx watch src/index.ts" }, "dependencies": { "@better-auth/expo": "^1.2.5-beta.10", "@hono/node-server": "^1.14.0", "better-auth": "^1.2.5-beta.10", "better-sqlite3": "^11.9.1", "hono": "^4.7.5" }, "devDependencies": { "@types/better-sqlite3": "^7.6.12", "@types/node": "^20.11.17", "tsx": "^4.7.1" } } ``` ``` Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] | undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'. Types of parameters 'ctx' and 'ctx' are incompatible. Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.DVddfEHH", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.aaUJqbx0").l'. The types of 'options.database' are incompatible between these types. Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/ mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config"). PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'. Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'. Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'. The types of 'createAdapter().acquireMigrationLock' are incompatible between these types. Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution- mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/ dialect-adapter").MigrationLockOptions) => Promise<...>'. Types of parameters 'db' and 'db' are incompatible. Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'. Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. ```
Author
Owner

@Nikola-Milovic commented on GitHub (Apr 23, 2025):

This is still an issue with 1.2.7. It's still occuring on the backend

Seems like a duplicate of https://github.com/better-auth/better-auth/issues/2031, but its still not resolved.

<!-- gh-comment-id:2823523940 --> @Nikola-Milovic commented on GitHub (Apr 23, 2025): This is still an issue with `1.2.7`. It's still occuring on the backend ~~Seems like a duplicate of https://github.com/better-auth/better-auth/issues/2031, but its still not resolved~~.
Author
Owner

@Bekacru commented on GitHub (Apr 23, 2025):

@Nikola-Milovic could you send me your auth config and tsconfig?

<!-- gh-comment-id:2823673021 --> @Bekacru commented on GitHub (Apr 23, 2025): @Nikola-Milovic could you send me your auth config and tsconfig?
Author
Owner

@Nikola-Milovic commented on GitHub (Apr 23, 2025):

@Bekacru The reproduction steps still apply and can be recreated with the latest versions (for me at least)

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "NodeNext",
    "strict": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": true,
    "types": [
      "node"
    ],
    "jsx": "react-jsx",
    "jsxImportSource": "hono/jsx",
  }
}

main.ts

import { serve } from '@hono/node-server'
import { Hono } from 'hono'

const app = new Hono()

import { betterAuth } from "better-auth";
import Database from "better-sqlite3";
import { expo } from '@better-auth/expo';

export const auth = betterAuth({
	database: new Database("./sqlite.db"),
	plugins: [
		expo()
	],
})

app.get('/', (c) => {
	return c.text('Hello Hono!')
})

serve({
	fetch: app.fetch,
	port: 3000
}, (info) => {
	console.log(`Server is running on http://localhost:${info.port}`)
})

package.json

{
  "name": "my-app",
  "type": "module",
  "scripts": {
    "dev": "tsx watch src/index.ts"
  },
  "dependencies": {
    "@better-auth/expo": "^1.2.7",
    "@hono/node-server": "^1.14.1",
    "better-auth": "^1.2.7",
    "better-sqlite3": "^11.9.1",
    "hono": "^4.7.7"
  },
  "devDependencies": {
    "@types/better-sqlite3": "^7.6.13",
    "@types/node": "^20.11.17",
    "tsx": "^4.7.1"
  }
}

The error

Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] |
    undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.
        Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.qzSbzJNO", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.B3qlboSE").l'.
          The types of 'options.database' are incompatible between these types.
            Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/
            mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config").
            PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'.
              Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'.
                Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'.
                  The types of 'createAdapter().acquireMigrationLock' are incompatible between these types.
                    Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution-
                    mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/
                    dialect-adapter").MigrationLockOptions) => Promise<...>'.
                      Types of parameters 'db' and 'db' are incompatible.
                        Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'.
                          Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. [2322]
<!-- gh-comment-id:2823691478 --> @Nikola-Milovic commented on GitHub (Apr 23, 2025): @Bekacru The reproduction steps still apply and can be recreated with the latest versions (for me at least) `tsconfig.json` ```json { "compilerOptions": { "target": "ESNext", "module": "NodeNext", "strict": true, "verbatimModuleSyntax": true, "skipLibCheck": true, "types": [ "node" ], "jsx": "react-jsx", "jsxImportSource": "hono/jsx", } } ``` `main.ts` ``` import { serve } from '@hono/node-server' import { Hono } from 'hono' const app = new Hono() import { betterAuth } from "better-auth"; import Database from "better-sqlite3"; import { expo } from '@better-auth/expo'; export const auth = betterAuth({ database: new Database("./sqlite.db"), plugins: [ expo() ], }) app.get('/', (c) => { return c.text('Hello Hono!') }) serve({ fetch: app.fetch, port: 3000 }, (info) => { console.log(`Server is running on http://localhost:${info.port}`) }) ``` `package.json` ```json { "name": "my-app", "type": "module", "scripts": { "dev": "tsx watch src/index.ts" }, "dependencies": { "@better-auth/expo": "^1.2.7", "@hono/node-server": "^1.14.1", "better-auth": "^1.2.7", "better-sqlite3": "^11.9.1", "hono": "^4.7.7" }, "devDependencies": { "@types/better-sqlite3": "^7.6.13", "@types/node": "^20.11.17", "tsx": "^4.7.1" } } ``` The error ``` Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { appName?: string | undefined; baseURL?: string | undefined; trustedOrigins?: (string | undefined)[] | undefined; newSession?: { ...; } | ... 1 more ... | undefined; ... 15 more ...; runMigrations?: (() => Promise<...>) | undefined; } | undefined; options?: Partial<...> | un...'. Types of parameters 'ctx' and 'ctx' are incompatible. Type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.qzSbzJNO", { with: { "resolution-mode": "import" } }).l' is not assignable to type 'import("/tmp/my-app/node_modules/better-auth/dist/shared/better-auth.B3qlboSE").l'. The types of 'options.database' are incompatible between these types. Type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect-config", { with: { "resolution-mode": "import" } }).PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/ mysql/mysql-dialect-config", { with: { "resolution-mode": "import" } }).MysqlPool | ....' is not assignable to type 'BetterSqlite3.Database | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/postgres/postgres-dialect-config"). PostgresPool | import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/mysql/mysql-dialect-config").MysqlPool | ... 4 more ... | undefined'. Type 'Dialect' is not assignable to type 'Database | PostgresPool | MysqlPool | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; casing?: "snake" | ... 1 more ... | undefined; } | { ...; } | undefined'. Type 'import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect", { with: { "resolution-mode": "import" } }).Dialect' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/dialect").Dialect'. The types of 'createAdapter().acquireMigrationLock' are incompatible between these types. Type '(db: import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/esm/dialect/dialect-adapter", { with: { "resolution- mode": "import" } }).MigrationLockOptions) => Promise<...>' is not assignable to type '(db: import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>, options: import("/tmp/my-app/node_modules/kysely/dist/cjs/dialect/ dialect-adapter").MigrationLockOptions) => Promise<...>'. Types of parameters 'db' and 'db' are incompatible. Type 'import("/tmp/my-app/node_modules/kysely/dist/cjs/kysely").Kysely<any>' is not assignable to type 'import("/tmp/my-app/node_modules/kysely/dist/esm/kysely", { with: { "resolution-mode": "import" } }).Kysely<any>'. Property '#private' in type 'Kysely' refers to a different member that cannot be accessed from within type 'Kysely'. [2322] ```
Author
Owner

@Bekacru commented on GitHub (Apr 23, 2025):

if you disable verbatimModuleSyntax it should. Will look into it.

<!-- gh-comment-id:2823771765 --> @Bekacru commented on GitHub (Apr 23, 2025): if you disable `verbatimModuleSyntax` it should. Will look into it.
Author
Owner

@mezotv commented on GitHub (Apr 30, 2025):

Also ran into this issue, any updates on a possible fix?

<!-- gh-comment-id:2843522846 --> @mezotv commented on GitHub (Apr 30, 2025): Also ran into this issue, any updates on a possible fix?
Author
Owner

@berkerdemirer commented on GitHub (May 2, 2025):

Any updates on this?

<!-- gh-comment-id:2847910952 --> @berkerdemirer commented on GitHub (May 2, 2025): Any updates on this?
Author
Owner

@Kinfe123 commented on GitHub (May 3, 2025):

can you try installing this one - npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@2526

<!-- gh-comment-id:2848709920 --> @Kinfe123 commented on GitHub (May 3, 2025): can you try installing this one - `npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@2526`
Author
Owner

@mezotv commented on GitHub (May 3, 2025):

can you try installing this one - npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@2526

Doesn't seem to work for me.

<!-- gh-comment-id:2848714012 --> @mezotv commented on GitHub (May 3, 2025): > can you try installing this one - `npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@2526` Doesn't seem to work for me.
Author
Owner

@Kinfe123 commented on GitHub (May 3, 2025):

also do the same for the better auth - npm i https://pkg.pr.new/better-auth/better-auth@2526

<!-- gh-comment-id:2848716370 --> @Kinfe123 commented on GitHub (May 3, 2025): also do the same for the better auth - `npm i https://pkg.pr.new/better-auth/better-auth@2526`
Author
Owner

@mezotv commented on GitHub (May 3, 2025):

also do the same for the better auth - npm i https://pkg.pr.new/better-auth/better-auth@2526

Doesn't seem to work with that either.

<!-- gh-comment-id:2848718029 --> @mezotv commented on GitHub (May 3, 2025): > also do the same for the better auth - `npm i https://pkg.pr.new/better-auth/better-auth@2526` Doesn't seem to work with that either.
Author
Owner

@Kinfe123 commented on GitHub (May 3, 2025):

what exactly you seeing ? may be try reloading your editor or restart ts server ?

<!-- gh-comment-id:2848726500 --> @Kinfe123 commented on GitHub (May 3, 2025): what exactly you seeing ? may be try reloading your editor or restart ts server ?
Author
Owner

@mezotv commented on GitHub (May 3, 2025):

what exactly you seeing ? may be try reloading your editor or restart ts server ?

Getting the same error as before and yes I restarted the ts server, my vscode and did a clean install of my packages.

Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
<!-- gh-comment-id:2848734244 --> @mezotv commented on GitHub (May 3, 2025): > what exactly you seeing ? may be try reloading your editor or restart ts server ? Getting the same error as before and yes I restarted the ts server, my vscode and did a clean install of my packages. ``` Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. ```
Author
Owner

@berkerdemirer commented on GitHub (May 4, 2025):

getting exact same error

<!-- gh-comment-id:2849206625 --> @berkerdemirer commented on GitHub (May 4, 2025): getting exact same error
Author
Owner

@Kinfe123 commented on GitHub (May 4, 2025):

@berkerdemirer are you using hono ? or something else

<!-- gh-comment-id:2849223820 --> @Kinfe123 commented on GitHub (May 4, 2025): @berkerdemirer are you using hono ? or something else
Author
Owner

@berkerdemirer commented on GitHub (May 4, 2025):

I'm using hono, if you wish I can put up the repo. I am using pnpm to install the packages

<!-- gh-comment-id:2849249492 --> @berkerdemirer commented on GitHub (May 4, 2025): I'm using hono, if you wish I can put up the repo. I am using pnpm to install the packages
Author
Owner

@berkerdemirer commented on GitHub (May 4, 2025):

@Kinfe123

<!-- gh-comment-id:2849374720 --> @berkerdemirer commented on GitHub (May 4, 2025): @Kinfe123
Author
Owner

@Kinfe123 commented on GitHub (May 5, 2025):

can you please share your tsconfig file ?

<!-- gh-comment-id:2851254570 --> @Kinfe123 commented on GitHub (May 5, 2025): can you please share your tsconfig file ?
Author
Owner

@Kinfe123 commented on GitHub (May 5, 2025):

can you use this tsconfig

{
  "compilerOptions": {
    "target": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "skipLibCheck": true,
    "types": [
      "node"
    ],
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "noEmit": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "incremental": true,
    "jsxImportSource": "hono/jsx",
    "jsx": "preserve",
  }
}

along with the above command to install new changes regarding to this issue

<!-- gh-comment-id:2851394909 --> @Kinfe123 commented on GitHub (May 5, 2025): can you use this tsconfig ```ts { "compilerOptions": { "target": "ESNext", "moduleResolution": "bundler", "strict": true, "skipLibCheck": true, "types": [ "node" ], "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "noEmit": true, "esModuleInterop": true, "resolveJsonModule": true, "isolatedModules": true, "incremental": true, "jsxImportSource": "hono/jsx", "jsx": "preserve", } } ``` along with the above command to install new changes regarding to this issue
Author
Owner

@berkerdemirer commented on GitHub (May 5, 2025):

my config:

{ "extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "target": "ESNext", "module": "NodeNext", "outDir": "./dist", "rootDir": ".", "strict": true, "verbatimModuleSyntax": true, "skipLibCheck": true, "types": ["node"], "jsx": "react-jsx", "allowImportingTsExtensions": true, "noEmit": true, "jsxImportSource": "hono/jsx" }, "include": ["**/*.ts"], "exclude": ["dist"] }

<!-- gh-comment-id:2851691262 --> @berkerdemirer commented on GitHub (May 5, 2025): my config: `{ "extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "target": "ESNext", "module": "NodeNext", "outDir": "./dist", "rootDir": ".", "strict": true, "verbatimModuleSyntax": true, "skipLibCheck": true, "types": ["node"], "jsx": "react-jsx", "allowImportingTsExtensions": true, "noEmit": true, "jsxImportSource": "hono/jsx" }, "include": ["**/*.ts"], "exclude": ["dist"] }`
Author
Owner

@Kinfe123 commented on GitHub (May 5, 2025):

have you adjusted with what i have mentioned above ?

<!-- gh-comment-id:2851959729 --> @Kinfe123 commented on GitHub (May 5, 2025): have you adjusted with what i have mentioned above ?
Author
Owner

@berkerdemirer commented on GitHub (May 5, 2025):

yes this tsconfig worked, so what caused this problem?

<!-- gh-comment-id:2851973721 --> @berkerdemirer commented on GitHub (May 5, 2025): yes this tsconfig worked, so what caused this problem?
Author
Owner

@Kinfe123 commented on GitHub (May 5, 2025):

you should disable verbatimModuleSyntax along with the flag that affects it.

<!-- gh-comment-id:2851983907 --> @Kinfe123 commented on GitHub (May 5, 2025): you should disable `verbatimModuleSyntax` along with the flag that affects it.
Author
Owner

@berkerdemirer commented on GitHub (May 5, 2025):

To me, it seems like it is rather moduleResolution that did the fix. Because, if i remove verbatimModuleSyntax error is still there

<!-- gh-comment-id:2852006838 --> @berkerdemirer commented on GitHub (May 5, 2025): To me, it seems like it is rather moduleResolution that did the fix. Because, if i remove verbatimModuleSyntax error is still there
Author
Owner

@Kinfe123 commented on GitHub (May 5, 2025):

yeah moduleResolution is was one of the related issues.

<!-- gh-comment-id:2852057589 --> @Kinfe123 commented on GitHub (May 5, 2025): yeah moduleResolution is was one of the related issues.
Author
Owner

@eth0izzle commented on GitHub (May 6, 2025):

Also getting the same issue but @Kinfe123 your tsconfig doesn't work for me. I'm using Deno rather then Node.

Although everything compiles so my workaround for now is just to //@ts-ignore it.

<!-- gh-comment-id:2856213150 --> @eth0izzle commented on GitHub (May 6, 2025): Also getting the same issue but @Kinfe123 your tsconfig doesn't work for me. I'm using Deno rather then Node. Although everything compiles so my workaround for now is just to `//@ts-ignore` it.
Author
Owner

@erquhart commented on GitHub (May 10, 2025):

Ran into this when npm linking to a local copy of better auth - same error but without using the expo package. It's likely that better-auth and @better-auth/expo imports are not referencing the same better-auth module for folks experiencing this.

<!-- gh-comment-id:2869145232 --> @erquhart commented on GitHub (May 10, 2025): Ran into this when npm linking to a local copy of better auth - same error but without using the expo package. It's likely that better-auth and @better-auth/expo imports are not referencing the same better-auth module for folks experiencing this.
Author
Owner

@iamdanajr commented on GitHub (Jun 26, 2025):

Hi, The issue is related to TS, just a workaroud

export const auth = betterAuth({
database: new Database("./sqlite.db"),
plugins: [
expo() as BetterAuthPlugin // Cast the expo plugin and ts will be happy
],
})

<!-- gh-comment-id:3009767712 --> @iamdanajr commented on GitHub (Jun 26, 2025): Hi, The issue is related to TS, just a workaroud export const auth = betterAuth({ database: new Database("./sqlite.db"), plugins: [ expo() as BetterAuthPlugin // Cast the expo plugin and ts will be happy ], })
Author
Owner

@Fyrlex commented on GitHub (Aug 16, 2025):

I want to bump this issue. Type error with expo() as a plugin still occurring on better-auth@1.3.6 and @better-auth/expo@1.3.6.

Node 24
Typescript 5.8.3
TSConfig

{
  "compilerOptions": {
    "incremental": true,
    "target": "es2024",
    "lib": ["ES2024"],
    "module": "NodeNext",
    "rootDir": "./src/",
    "moduleResolution": "NodeNext",
    "resolveJsonModule": true,
    "sourceMap": true,
    "jsx": "react-jsx",
    "outDir": "./build/src",
    "removeComments": true,
    "isolatedModules": true,
    "esModuleInterop": true,
    "strict": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["./src/**/*.ts"]
}
<!-- gh-comment-id:3193683185 --> @Fyrlex commented on GitHub (Aug 16, 2025): I want to bump this issue. Type error with `expo()` as a plugin still occurring on better-auth@1.3.6 and @better-auth/expo@1.3.6. Node 24 Typescript 5.8.3 TSConfig ```json { "compilerOptions": { "incremental": true, "target": "es2024", "lib": ["ES2024"], "module": "NodeNext", "rootDir": "./src/", "moduleResolution": "NodeNext", "resolveJsonModule": true, "sourceMap": true, "jsx": "react-jsx", "outDir": "./build/src", "removeComments": true, "isolatedModules": true, "esModuleInterop": true, "strict": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": ["./src/**/*.ts"] } ```
Author
Owner

@Kinfe123 commented on GitHub (Aug 17, 2025):

it should be fixed on the latest patch releases. via #4037

<!-- gh-comment-id:3194263250 --> @Kinfe123 commented on GitHub (Aug 17, 2025): it should be fixed on the latest patch releases. via #4037
Author
Owner

@demirtasdurmus commented on GitHub (Sep 22, 2025):

Still having this issue with

{
  "@better-auth/expo": "^1.3.13",
   "better-auth": "^1.3.13",
}
<!-- gh-comment-id:3318978537 --> @demirtasdurmus commented on GitHub (Sep 22, 2025): Still having this issue with ```json { "@better-auth/expo": "^1.3.13", "better-auth": "^1.3.13", } ```
Author
Owner

@Akashamba commented on GitHub (Oct 7, 2025):

I still have this issue on better-auth@1.3.26 and @better-auth/expo@1.3.26 in an express app. but auth works just fine even with with the error, and using //@ts-ignore suppresses the error. interestingly, when building on vercel, using //@ts-ignore gives me a build error for an unnecessary directive, while it builds and works just fine without any errors when I remove the //@ts-ignore

pretty sure it’s just a typescript issue not a runtime one, but idk how to make the red squiggles go away :'(

<!-- gh-comment-id:3374730187 --> @Akashamba commented on GitHub (Oct 7, 2025): I still have this issue on ```better-auth@1.3.26``` and ```@better-auth/expo@1.3.26``` in an express app. but auth works just fine even with with the error, and using ```//@ts-ignore``` suppresses the error. interestingly, when building on vercel, using ```//@ts-ignore``` gives me a build error for an unnecessary directive, while it builds and works just fine without any errors when I remove the ```//@ts-ignore``` pretty sure it’s just a typescript issue not a runtime one, but idk how to make the red squiggles go away :'(
Author
Owner

@Nikola-Milovic commented on GitHub (Oct 7, 2025):

@Akashamba it is a typescript issue, so you can for now, just use the as any or as BetterAuthPlugin

	plugins: [
		expo() as any
	],
<!-- gh-comment-id:3377533978 --> @Nikola-Milovic commented on GitHub (Oct 7, 2025): @Akashamba it is a typescript issue, so you can for now, just use the `as any` or `as BetterAuthPlugin` ``` plugins: [ expo() as any ], ```
Author
Owner

@Akashamba commented on GitHub (Oct 8, 2025):

@Nikola-Milovic thank you for your reply. yes, this is the temporary solution I have reached for now. out of curiosity, who would be responsible for a proper fix here? would this fall under better-auth, expo, typescript, or am I just using better-auth in a way it’s not really intended to be used?

<!-- gh-comment-id:3382723871 --> @Akashamba commented on GitHub (Oct 8, 2025): @Nikola-Milovic thank you for your reply. yes, this is the temporary solution I have reached for now. out of curiosity, who would be responsible for a proper fix here? would this fall under better-auth, expo, typescript, or am I just using better-auth in a way it’s not really intended to be used?
Author
Owner

@Nikola-Milovic commented on GitHub (Oct 8, 2025):

@Akashamba you're doing everything as intended. It's an issue with the type definitions in better auth library.

As long as you're following the docs, you're doing it right.

<!-- gh-comment-id:3383019286 --> @Nikola-Milovic commented on GitHub (Oct 8, 2025): @Akashamba you're doing everything as intended. It's an issue with the type definitions in better auth library. As long as you're following the docs, you're doing it right.
Author
Owner

@himself65 commented on GitHub (Oct 10, 2025):

Can you make sure you have the same version with better-auth?

<!-- gh-comment-id:3392597703 --> @himself65 commented on GitHub (Oct 10, 2025): Can you make sure you have the same version with better-auth?
Author
Owner

@himself65 commented on GitHub (Oct 10, 2025):

I'm trying to fix this. I can see the bug locally

<!-- gh-comment-id:3392603999 --> @himself65 commented on GitHub (Oct 10, 2025): I'm trying to fix this. I can see the bug locally
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26314