Next.js Discord

Discord Forum

How to Modify the Prisma Adapter for Token-Based Authentication in NextAuth.js?

Unanswered
Raspberry Horntail posted this in #help-forum
Open in Discord
Raspberry HorntailOP
I’m integrating OAuth into my application using NextAuth.js. I’ve already implemented a token-based authentication system and made some modifications to get it working with NextAuth’s Credentials Provider for handling sessions.

However, when integrating the Prisma Adapter, I found that it requires a Session model, which I want to replace with my Token model to store refresh tokens upon user login.
My Custom Token Model (Prisma)

model Token {
  id       String  @id @default(uuid())
  token    String  @unique @map("hashedToken")
  userId   String
  User     User    @relation(fields: [userId], references: [id], onDelete: Cascade)
  revoked  Boolean @default(false)
  expireAt Int // Stored in minutes

  @@index([token])
}


Is there an existing solution or a recommended approach to modify the Prisma Adapter to work with this token-based authentication setup?

0 Replies