D1 incorrect dialect

I'm trying to create an auth instance with D1 and getting an error like Type 'D1Dialect' is not assignable to type 'Dialect'. The types returned by 'createDriver().acquireConnection()' are incompatible between these types. Type 'Promise<import("<my-project>/node_modules/kysely/dist/esm/driver/database-connection").DatabaseConnection>' is not assignable to type 'Promise<import("<my-project>/node_modules/better-auth/node_modules/kysely/dist/esm/driver/database-connection").DatabaseConnection>'. My code is like:
import { D1Dialect } from "kysely-d1";
import { betterAuth } from "better-auth";

export const auth = (env: Env) =>
betterAuth({
database: {
dialect: new D1Dialect({
database: env.DB,
}),
type: "sqlite",
},
// .. the rest
import { D1Dialect } from "kysely-d1";
import { betterAuth } from "better-auth";

export const auth = (env: Env) =>
betterAuth({
database: {
dialect: new D1Dialect({
database: env.DB,
}),
type: "sqlite",
},
// .. the rest
Any suggestions?
Solution:
Following up if anyone encounters this in the future. Could resolve this by using older versions of kysely-d1 and kysely. Relevant package dependencies look like: ``` "better-auth": "^1.2.7",...
Jump to solution
2 Replies
Ping
Ping3d ago
I see a lot of users using something like Drizzle Adapter to make this work
Solution
stu
stu2d ago
Following up if anyone encounters this in the future. Could resolve this by using older versions of kysely-d1 and kysely. Relevant package dependencies look like:
"better-auth": "^1.2.7",
"kysely": "^0.27.4",
"kysely-d1": "^0.3.0",
"better-auth": "^1.2.7",
"kysely": "^0.27.4",
"kysely-d1": "^0.3.0",

Did you find this page helpful?