Prisma Adapter with Auth.js in Next.js 15 on Vercel (Edge Runtime Issue) #13010
Unanswered
Michall396
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I have a Turbo repo with the following structure:
Database: Supabase (free account)
Deployment: Vercel (free account)
This is my first Next.js app, and I might be facing a trivial issue, but I've been stuck on it for an entire day.
Context
Local Development: I use a PostgreSQL database via Docker or Supabase.
Authentication and database access work perfectly.
Vercel Build: The build process on Vercel works fine.
Database Access: Supabase with Prisma works when Auth.js authentication is disabled.
Issue: When I enable Auth.js authentication, I encounter an error :
/api/auth/session
It seems the issue is related to the Prisma Adapter in Auth.js. I suspect the problem arises because Vercel's middleware runs on the Edge runtime, while the Prisma Adapter requires a Node.js runtime.
Configuration Details
Next.js App (apps/web)
Dependencies:
next.config.mjs:
app/api/auth/[...nextauth]
@repo/authjs-core
Dependencies:
auth.config.ts:
index.ts (uses Prisma exported from @repo/database):
@repo/database
Dependencies:
Structure:
schema.prisma:
index.ts:
Problem
The issue appears to be with the Prisma Adapter in Auth.js when deployed on Vercel. Since Vercel's middleware runs on the Edge runtime, and Prisma requires a Node.js runtime, this mismatch likely causes the error. I need guidance on how to resolve this compatibility issue or alternative approaches to make Auth.js with Prisma work on Vercel.
Any suggestions for workarounds or alternative setups are appreciated!
Beta Was this translation helpful? Give feedback.
All reactions