PrismaClient is not configured to run in Edge Runtime

Stack: SvelteKit, Vercel, Prisma (Neon adapter) & Better Auth I've tried so many solutions I can't even recall half of them. I've spent about three hours trying to get everything up and running and I just can't get rid of this error (attached) Here's my related files, if anyone can help solve this I'd be forever grateful. build cmd: "build": "npx prisma generate && vite build", schema.prisma:
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DATABASE_URL_UNPOOLED")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DATABASE_URL_UNPOOLED")
}
lib/prisma.ts:
import { Pool, neonConfig } from "@neondatabase/serverless";

import { DATABASE_URL } from "$env/static/private";
import { PrismaClient } from "@prisma/client";
import { PrismaNeon } from "@prisma/adapter-neon";
import ws from "ws";

neonConfig.webSocketConstructor = ws;

const pool = new Pool({ connectionString: DATABASE_URL });
const adapter = new PrismaNeon(pool);
const prisma = new PrismaClient({ adapter });

export default prisma;
import { Pool, neonConfig } from "@neondatabase/serverless";

import { DATABASE_URL } from "$env/static/private";
import { PrismaClient } from "@prisma/client";
import { PrismaNeon } from "@prisma/adapter-neon";
import ws from "ws";

neonConfig.webSocketConstructor = ws;

const pool = new Pool({ connectionString: DATABASE_URL });
const adapter = new PrismaNeon(pool);
const prisma = new PrismaClient({ adapter });

export default prisma;
svelte.config.js:
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
runtime: 'edge'
})
},
preprocess: vitePreprocess()
};
export default config;
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
runtime: 'edge'
})
},
preprocess: vitePreprocess()
};
export default config;
No description
3 Replies
π™»πšŠπšŒπš‘πš’πšŽ
It's getting to the stage that we're considering ditching Prisma, which we'd really prefer not to do πŸ™
Nurul
Nurulβ€’5w ago
Hey πŸ‘‹ I assume you would have seen this docs section of using Neon HTTP Driver: https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-vercel#neon Is your repository open source? Any way I can try to run this locally to debug? When exactly do you get this error? I see the error seems to be coming from better-auth package
Deploy to Vercel Edge Functions & Middleware | Prisma Documentation
Learn the things you need to know in order to deploy an Edge function that uses Prisma Client for talking to a database.
π™»πšŠπšŒπš‘πš’πšŽ
Hey mate, the repo isn’t open source but I’d be happy to share it privately if you’d be kind enough to add my. The error occurs when accessing anything from Prisma, whether auth is involved or not

Did you find this page helpful?