diff --git a/package.json b/package.json index faeb1ea..c289f5c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "lint": "next lint" }, "dependencies": { + "@auth/prisma-adapter": "^2.7.4", + "@prisma/client": "^6.1.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "lucide-react": "^0.469.0", @@ -20,13 +22,14 @@ "tailwindcss-animate": "^1.0.7" }, "devDependencies": { - "typescript": "^5", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", - "postcss": "^8", - "tailwindcss": "^3.4.1", "eslint": "^8", - "eslint-config-next": "15.0.3" + "eslint-config-next": "15.0.3", + "postcss": "^8", + "prisma": "^6.1.0", + "tailwindcss": "^3.4.1", + "typescript": "^5" } } diff --git a/src/auth.ts b/src/auth.ts index 3be7be6..580d157 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,5 +1,8 @@ import NextAuth from "next-auth"; +import { prisma } from "@/lib/prisma"; +import { PrismaAdapter } from "@auth/prisma-adapter"; export const { handlers, signIn, signOut, auth } = NextAuth({ + adapter: PrismaAdapter(prisma), providers: [], }); diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts new file mode 100644 index 0000000..0426feb --- /dev/null +++ b/src/lib/prisma.ts @@ -0,0 +1,7 @@ +import { PrismaClient } from "@prisma/client"; + +const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }; + +export const prisma = globalForPrisma.prisma || new PrismaClient(); + +if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;