I am trying to persist user data using PrismaAdapter with authjs. But getting following error.
[auth][details]: {} [auth][error] SessionTokenError: Read more at https://errors.authjs.dev#sessiontokenerror [auth][cause]: PrismaClientInitializationError: Invalid
prisma.session.findUnique()invocation:Accelerate has not been setup correctly. Make sure your client is using
.$extends(withAccelerate()). See https://pris.ly/d/accelerate-getting-started at dr.handleRequestError (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules_@prisma_client_bc7a7d4b..js:5663:39) at dr.handleAndLogRequestError (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@prisma_client_bc7a7d4b..js:5614:18) at dr.request (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@prisma_client_bc7a7d4b..js:5595:18) at async a (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@prisma_client_bc7a7d4b..js:6284:25) at async getSessionAndUser (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules_b35dcabe..js:55:36) at async acc. (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules_@auth_core_95a5547c..js:1621:24) at async Module.session (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@auth_core_95a5547c..js:4608:30) at async AuthInternal (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@auth_core_95a5547c..js:5132:24) at async Auth (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules@auth_core_95a5547c..js:5371:34) at async handleAuth (/home/himangshu/Documents/sharemore/.next/server/edge/chunks/node_modules_b35dcabe..js:4158:29)
Here is my auth.ts
import { PrismaAdapter } from "@auth/prisma-adapter";
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
import prisma from "./lib/prisma";
import { PrismaClient } from "@prisma/client";
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: PrismaAdapter(prisma as unknown as PrismaClient),
providers: [GitHub],
session: { strategy: "database" },
secret: process.env.AUTH_SECRET,
});
How to solve the issue?
DATABASE_URLenvironment variable is set and points to a valid database. If it is, please show us your./lib/prisma.tsfile..$extends(withAccelerate())to your existingprismainstantiation.