Username plugin with drizzle adapter gives Types errors

I was setting up a very simple better auth example with express (i know i know, but I'm doing an experiment ๐Ÿ˜„ ) but even before setting up anything I have this very weird type error when using the username plugin with the drizzle adapter.

import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { db } from '../db/index.ts'; // your drizzle instance
import { username } from 'better-auth/plugins';

export const auth = betterAuth({
    plugins: [username()],
    database: drizzleAdapter(db, {
        provider: 'sqlite',
    }),
});


here's my better auth instance...i did run generate and this is my drizzle instance

import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import * as schema from './schema.ts';

const client = createClient({
    url: 'file:notes.db',
});

export const db = drizzle(client, {
    schema,
});

i get this error:
Type '{ id: "username"; init(ctx: AuthContext): { options: { databaseHooks: { user: { create: { before(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; } & Record<...>, context: GenericEndpointContext | undefined): Promi...' is not assignable to type 'BetterAuthPlugin'.
// other stuff
                The types of 'data.id' are incompatible between these types.
                  Type 'string | undefined' is not assignable to type 'string'.
                    Type 'undefined' is not assignable to type 'string'.

7  plugins: [username()],

any ideas?
Was this page helpful?