P
Prisma2mo ago
gp999

PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware

I created a next.js (14.2.3) app and followed Auth.js documentation to add Goole OAUTH and prisma database (schema successfully initiated), now when I click "Sign In with Google" I see the following error in console:
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get (webpack-internal:///(middleware)/./node_modules/.prisma/client/index-browser.js:218:15)
at getSessionAndUser (webpack-internal:///(middleware)/./node_modules/@auth/prisma-adapter/index.js:28:44)
at acc.<computed> (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/init.js:178:30)
at Module.session (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/actions/session.js:67:36)
at AuthInternal (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/index.js:47:77)
at async Auth (webpack-internal:///(middleware)/./node_modules/@auth/core/index.js:126:34)
at async handleAuth (webpack-internal:///(middleware)/./node_modules/next-auth/lib/index.js:134:29)
at async adapter (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/adapter.js:179:16)
at async /home/gp99/my-app/node_modules/next/dist/server/web/sandbox/sandbox.js:110:22
at async runWithTaggedErrors (/home/gp99/next.js/my-app/node_modules/next/dist/server/web/sandbox/sandbox.js:107:9)
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get (webpack-internal:///(middleware)/./node_modules/.prisma/client/index-browser.js:218:15)
at getSessionAndUser (webpack-internal:///(middleware)/./node_modules/@auth/prisma-adapter/index.js:28:44)
at acc.<computed> (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/init.js:178:30)
at Module.session (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/actions/session.js:67:36)
at AuthInternal (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/index.js:47:77)
at async Auth (webpack-internal:///(middleware)/./node_modules/@auth/core/index.js:126:34)
at async handleAuth (webpack-internal:///(middleware)/./node_modules/next-auth/lib/index.js:134:29)
at async adapter (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/adapter.js:179:16)
at async /home/gp99/my-app/node_modules/next/dist/server/web/sandbox/sandbox.js:110:22
at async runWithTaggedErrors (/home/gp99/next.js/my-app/node_modules/next/dist/server/web/sandbox/sandbox.js:107:9)
2 Replies
gp999
gp9992mo ago
Auth.ts
import NextAuth from 'next-auth';
import Google from '@auth/core/providers/google';
import {PrismaAdapter} from '@auth/prisma-adapter';
import {PrismaClient} from '@prisma/client';

const prisma = new PrismaClient();
export const {handlers, signIn, signOut, auth} = NextAuth({
adapter: PrismaAdapter(prisma),
providers: [Google]
});
import NextAuth from 'next-auth';
import Google from '@auth/core/providers/google';
import {PrismaAdapter} from '@auth/prisma-adapter';
import {PrismaClient} from '@prisma/client';

const prisma = new PrismaClient();
export const {handlers, signIn, signOut, auth} = NextAuth({
adapter: PrismaAdapter(prisma),
providers: [Google]
});
packages.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth/prisma-adapter": "^2.1.0",
"@prisma/client": "^5.14.0",
"next": "14.2.3",
"next-auth": "^5.0.0-beta.18",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
"prisma": "^5.14.0",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@auth/prisma-adapter": "^2.1.0",
"@prisma/client": "^5.14.0",
"next": "14.2.3",
"next-auth": "^5.0.0-beta.18",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
"prisma": "^5.14.0",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
jonfanz
jonfanz2mo ago
The link in the error message (https://pris.ly/d/driver-adapters) should have more info on how to proceed
Database drivers | Prisma Documentation
Learn how Prisma connects to your database using the built-in drivers and how you can use Prisma along with other JavaScript database drivers using driver adapters (Preview)