0

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?

3
  • Make sure the DATABASE_URL environment variable is set and points to a valid database. If it is, please show us your ./lib/prisma.ts file. Commented Oct 23 at 9:20
  • Does Prisma Adapter need database URL with username and password? I am using Prisma accelerated connection string. Commented Oct 24 at 16:17
  • Ah, since you're using Prisma's Accelerate feature, the configuration should look a bit different. Essentially, you'll need to add .$extends(withAccelerate()) to your existing prisma instantiation. Commented Oct 25 at 4:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.