cannot infer type with drizzle adapter #1020

Closed
opened 2026-03-13 08:19:04 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jed-cheng on GitHub (Apr 9, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

typescript is set to strict mode

const client = postgres(process.env.DATABASE_URL);
const db = drizzle({ client, logger: true });
export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg", // or "pg" or "mysql"
  }), 
  plugins: []
  //... the rest of your config
});
export type Session = typeof auth.$Infer.Session

Current vs. Expected behavior

Image
expected to infer type of session and user

What version of Better Auth are you using?

1.2.5

Provide environment information

- OS: Ubuntu 22.04.5 LTS
- Node.js v22.9.0
- drizzle-orm  0.41.0

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

Backend

Additional context

No response

Originally created by @jed-cheng on GitHub (Apr 9, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce typescript is set to strict mode ``` typescript const client = postgres(process.env.DATABASE_URL); const db = drizzle({ client, logger: true }); export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", // or "pg" or "mysql" }), plugins: [] //... the rest of your config }); export type Session = typeof auth.$Infer.Session ``` ### Current vs. Expected behavior ![Image](https://github.com/user-attachments/assets/d128f28d-f812-416f-ae7e-e18aaeeab61f) expected to infer type of session and user ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - OS: Ubuntu 22.04.5 LTS - Node.js v22.9.0 - drizzle-orm 0.41.0 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Additional context _No response_
Author
Owner

@Kinfe123 commented on GitHub (Apr 9, 2025):

have you generated the schema's and pushed yet ?

npx @better-auth/cli generate

@Kinfe123 commented on GitHub (Apr 9, 2025): have you generated the schema's and pushed yet ? `npx @better-auth/cli generate`
Author
Owner

@jed-cheng commented on GitHub (Apr 10, 2025):

The issue was resolved after regenerating the schema. Everything is working fine now, thanks for your help!

@jed-cheng commented on GitHub (Apr 10, 2025): The issue was resolved after regenerating the schema. Everything is working fine now, thanks for your help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1020