next-auth: prisma adapter types error
Adapter type
Environment
System:
OS: Windows 10 10.0.19045
Memory: 991.97 MB / 5.95 GB
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - C:\Program Files\nodejs\yarn.CMD
npm: 8.16.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.54)
Internet Explorer: 11.0.19041.1566
npmPackages: @next-auth/prisma-adapter: ^1.0.5 => 1.0.5
Reproduction URL
https://github.com/OrJDev/nextauth-error-repro
Describe the issue
Type 'Adapter<boolean>' is not assignable to type 'Adapter<boolean> | undefined'.
Type 'DefaultAdapter' is not assignable to type 'Adapter<boolean> | undefined'.
Type 'DefaultAdapter' is not assignable to type 'DefaultAdapter & { createVerificationToken: (verificationToken: VerificationToken) => Awaitable<VerificationToken | null | undefined>; useVerificationToken: (params: { ...; }) => Awaitable<...>; }'.
Type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/adapters").DefaultAdapter' is not assignable to type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/adapters").DefaultAdapter'.
Types of property 'linkAccount' are incompatible.
Type '(account: import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/adapters").AdapterAccount) => Promise<void> | import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/core/types").Awaitable<import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/adapters").Adapt...' is not assignable to type '(account: import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/adapters").AdapterAccount) => Promise<void> | import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/lib/types").Awaitable<import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/adapters").Ada...'.
Types of parameters 'account' and 'account' are incompatible.
Type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/adapters").AdapterAccount' is not assignable to type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/adapters").AdapterAccount'.
Types of property 'type' are incompatible.
Type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/@auth/core/providers/index").ProviderType' is not assignable to type 'import("c:/Users/\u05D0\u05D5\u05E8/Desktop/my-app/node_modules/next-auth/providers/index").ProviderType'.
Type '"oidc"' is not assignable to type 'ProviderType'.ts(2322)
How to reproduce
run
npm create jd-app@latest
select prisma and nextauth go to src/routes/api/auth/[…solidauth].ts the error will be there
Expected behavior
shouldn’t throw any type errors with a normal prisma client (no extension)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 17 (1 by maintainers)
try this
P.S. No matter which adapter you have, it should help with every adapters
I got the feedback that
Type 'Adapter' is not generic.
I can confirm that I’m still having type errors with the latest versions:
Using this Schema.
Error:
No errors when using latest
@next-auth/prisma-adapter
@Puetz as
@next-auth
is becoming@auth
that’s probably not the right way.@OrJDev please re-open as the problem still persists, even with latest
@auth/prisma-adapter
.use
@auth/prisma-adapter
to solve this issueHad this same issue in a SvelteKit project. Type assertion worked for me and didn’t get errors on runtime, should be a good temporary solution.
Why was this issue closed? I just set up my Next JS project with
and I’m having the exact same problems as everyone mentioned.
So I installed
"@next-auth/prisma-adapter": "^1.0.7"
which works for me.Please fix either your documentation about the prisma adapter or fix the type error for the newest versions of
next-auth
and@auth/prisma-adapter
.Not sure if it can help someone, but I solved it by using:
With versions:
This fixed my problem also. I think they should update a documentation a bit. Maybe we can help them? Open a pr? Because right now i feel a bit lost.
Looks like the module @next-auth/adapters is no longer existing, so the only solution is using @next-auth/prisma-adapter. I would suggest fixing the docs, or fixing the package
Which Schema should I use with “@next-auth/prisma-adapter”? The one shown in the v3 version or the one shown for “@auth/prisma-adapter”?
next-auth v3: https://next-auth.js.org/v3/adapters/prisma auth: https://authjs.dev/reference/adapter/prisma
@ShriPunta this is more about the
Adapter
and typescript types I think. Adding theAdapter
worked for prisma as wellTypeORMAdapter is a sibling or alternative to PrismaAdapter, both are one of the many adapters for next-auth
Hi @YuraD can you please explain with more context. I am not able to understand what is
connection
here? Also what do you mean byTypeORMAdapter
? where can I import this function?I am errors in the Prisma adapter
index.ts
One of the errors:
+1