Next.js Discord

Discord Forum

Error with Next Auth and prisma adapter

Unanswered
LuCrypto posted this in #help-forum
Open in Discord
Hello Next JS community, it's great to be here!

I'm here because I have a problem with Next Auth and adapt prisma.
Indeed, when I plug prisma, it doesn't work anymore and I don't understand why.

Here is my error (on first image)
and in the server console (on 2nd image)

My auth.ts
import NextAuth from "next-auth";
import Google from "next-auth/providers/google"

import { PrismaAdapter } from "@auth/prisma-adapter"
import { prisma } from "./prisma";

export const { auth, handlers } = NextAuth({
  adapter: PrismaAdapter({ prisma }),
  providers: [Google({
    clientId: process.env.AUTH_GOOGLE_ID ?? "",
    clientSecret: process.env.AUTH_GOOGLE_SECRET ?? "",
  })],
});


package.json
{
  "name": "whalesfinder",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "vercel-build": "prisma generate && prisma migrate deploy && next build"
  },
  "dependencies": {
    "@auth/prisma-adapter": "^2.0.0",
    "@prisma/client": "^5.13.0",
    "@tippy.js/react": "^3.1.1",
    "@types/node": "20.11.30",
    "@types/react": "18.2.67",
    "@types/react-dom": "18.2.22",
    "autoprefixer": "10.4.19",
    "chart.js": "^4.4.2",
    "eslint": "8.57.0",
    "eslint-config-next": "14.1.4",
    "ethers": "^5.7.2",
    "gsap": "^3.12.5",
    "moralis": "^2.25.2",
    "next": "14.1.4",
    "next-auth": "^5.0.0-beta.16",
    "postcss": "8.4.38",
    "react": "18.2.0",
    "react-chartjs-2": "^5.2.0",
    "react-dom": "18.2.0",
    "react-slick": "^0.30.2",
    "slick-carousel": "^1.8.1",
    "tailwindcss": "3.4.1",
    "tippy.js": "^6.3.7",
    "typescript": "5.4.3"
  },
  "devDependencies": {
    "@types/react-slick": "^0.23.13",
    "daisyui": "^4.7.3",
    "prisma": "^5.12.1"
  }
}


I've been on it for 2 days now, I can't figure out where the error came from...

8 Replies

I find, don't use next auth version 5 but 4 and next-auth/adapters instead of auth/adapters
Northeast Congo Lion
Next auth is all screwy for me as well. I already setup next-auth so I'm living with it.......... did the same thing you did btw
Do you use TypeScript ?
In my auth.ts i have this line for the Adapter :
`adapter : PrismaAdapter(prisma) as Adapterˋ
Ignore the backquotes they’re extra
prisma is from the prisma singleton export
You can find it on google pretty easily
Tan
https://nextjs-forum.com/post/1233779502468042863#message-1233811843378581574
In my case, the problem was not solved.
So, I used other solution.