#PrismaClient is not configured to run in Edge Runtime

4 messages · Page 1 of 1 (latest)

ocean raven
#

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:

  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;

svelte.config.js:

import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter({
            runtime: 'edge'
        })
    },
    preprocess: vitePreprocess()
};
export default config;
neat krakenBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

ocean raven
#

It's getting to the stage that we're considering ditching Prisma, which we'd really prefer not to do 🙏

ember isle
#

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

Learn the things you need to know in order to deploy an Edge function that uses Prisma Client for talking to a database.