PrismaP
Prisma2y ago
17 replies
Nik Revenco

Prisma Client is not configured to run in the edge runtime

I am not using the edge runtime. I am using the nodejs runtime!

No Error:
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as { db: PrismaClient };
const db = globalForPrisma.db || new PrismaClient();

export default db;

if (process.env.NODE_ENV !== "production") globalForPrisma.db = db;


Yes Error:
import { PrismaClient } from "@prisma/client";

const extension = {
  model: {
    user: {
      testing() {
        return "testing";
      },
    },
  },
};

const getExtendedPrismaClient = () => {
  return new PrismaClient().$extends(extension);
};

type ExtendedPrismaClient = ReturnType<typeof getExtendedPrismaClient>;

const globalForPrisma = globalThis as unknown as { db: ExtendedPrismaClient };
const db = globalForPrisma.db || getExtendedPrismaClient();

export default db;

if (process.env.NODE_ENV !== "production") globalForPrisma.db = db;
image.png
Was this page helpful?