Profile picture

Software Engineer (Open Source, Dev Tools) at BoxyHQ.

Follow me on Twitter

Next.js - Prisma Setup

August 09, 2022

import { PrismaClient } from "@prisma/client";

declare global {
  // allow global `var` declarations
  // eslint-disable-next-line no-var
  var prisma: PrismaClient | undefined;
}

export const prisma =
  global.prisma ||
  new PrismaClient({
    log: ["query"],
  });

if (process.env.NODE_ENV !== "production") global.prisma = prisma;

Kiran K