nextauthjs / nextauthjs/next-auth

DrizzleAdapter Type error

Open
#12,211 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

adapters bug triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Adapter type

@auth/drizzle-adapter

Environment

  System:
    OS: Linux 6.10 Manjaro Linux
    CPU: (4) x64 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz
    Memory: 1.70 GB / 7.47 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.2.0 - ~/.nvm/versions/node/v22.2.0/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v22.2.0/bin/npm
    pnpm: 9.8.0 - ~/.local/share/pnpm/pnpm
    bun: 1.1.17 - ~/.bun/bin/bun
  npmPackages:
    @auth/drizzle-adapter: ^1.7.3 => 1.7.3 
    next: 14.2.5 => 14.2.5 
    next-auth: 5.0.0-beta.25 => 5.0.0-beta.25 
    react: ^18.3.1 => 18.3.1 
Reproduction URL

https://github.com/IzaanAnwar/auth-ex/

Describe the issue

I have been getting this type error for so long and I have no clue how to fix it:

const authConfig = { adapter: DrizzleAdapter(db), session: { strategy: "jwt", }, // ........ more config }

And this line adapter: DrizzleAdapter(db), results in the following error:
Type 'AdapterUser' is not assignable to type 'Awaitable<AdapterUser>'. Type 'AdapterUser' is missing the following properties from type 'AdapterUser': role, accessToken, isSubActive, channelId, refreshToken

How to reproduce

"@auth/drizzle-adapter": "^1.7.3", and "drizzle-orm": "^0.36.1",

declare module "next-auth" {
interface Session {
user: {
id: UserId;
role: UserRole;
accessToken: string | null;
isSubActive: boolean | null;
channelId: string | null;
refreshToken: string | null;
} & DefaultSession["user"];
}
interface User {
id: UserId;
role: UserRole;
accessToken: string | null;
isSubActive: boolean | null;
channelId: string | null;
refreshToken: string | null;
}
}

Expected behavior

Should not get any type erros.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and inspect the TypeScript module augmentations for next-auth alongside the DrizzleAdapter configuration. Compare the declared User fields with the adapter's types and verify the result against the reported @auth/drizzle-adapter and next-auth versions; done means the configuration type-checks without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react, typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.