Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

NextJS 13 App Dir NextAuth Prisma Error - [next-auth][error][CLIENT_FETCH_ERROR] & [MISSING_ADAPTER_METHODS_ERROR] #35

Closed
@polooner

Description

I am using a Prisma adapter with a Supabase Postgres connection, I am unsure of what's going. I connected a SendGrid server for custom emails.

export const authOptions: NextAuthOptions = {
 adapter: PrismaAdapter(prisma as any),
 session: {
 strategy: 'jwt',
 },
 providers: [
 EmailProvider({
 server: {
 host: HOST,
 port: PORT,
 auth: {
 user: USER,
 pass: PASSWORD,
 },
 },
 from: FROM,
 }),
 ],
 callbacks: {
 session: ({ session, token }) => {
 console.log('Session Callback', { session, token });
 return {
 ...session,
 user: {
 ...session.user,
 id: token.id,
 randomKey: token.randomKey,
 },
 };
 },
 jwt: ({ token, user }) => {
 console.log('JWT Callback', { token, user });
 if (user) {
 const u = user as unknown as any;
 return {
 ...token,
 id: u.id,
 randomKey: u.randomKey,
 };
 }
 return token;
 },
 },
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
[next-auth][error][MISSING_ADAPTER_METHODS_ERROR] 
https://next-auth.js.org/errors#missing_adapter_methods_error Required adapter methods were missing: createVerificationToken, useVerificationToken, getUserByEmail MissingAdapterMethods [MissingAdapterMethodsError]: Required adapter methods were missing: createVerificationToken, useVerificationToken, getUserByEmail
 at assertConfig (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/assert.js:71:20)
 at AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:90:54)
 at processTicksAndRejections (node:internal/process/task_queues:96:5)
 at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)
 at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)
 at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37) {
 code: 'MISSING_ADAPTER_METHODS_ERROR'
}

This is my Prisma schema:

datasource db {
 provider = "postgresql"
 url = env("DATABASE_URL")
 directUrl = env("DIRECT_URL")
}
generator client {
 provider = "prisma-client-js"
}
model Account {
 id String @id @default(cuid())
 userId String
 type String
 provider String
 providerAccountId String
 refresh_token String? @db.Text
 access_token String? @db.Text
 expires_at Int?
 token_type String?
 scope String?
 id_token String? @db.Text
 session_state String?
 user User @relation(fields: [userId], references: [id], onDelete: Cascade)
 @@unique([provider, providerAccountId])
}
model Session {
 id String @id @default(cuid())
 sessionToken String @unique
 userId String
 expires DateTime
 user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User {
 id String @id @default(cuid())
 name String?
 email String? @unique
 emailVerified DateTime?
 image String?
 accounts Account[]
 sessions Session[]
}
model VerificationToken {
 identifier String
 token String @unique
 expires DateTime
 @@unique([identifier, token])
}

My prisma.ts file:

import { PrismaClient } from '@prisma/client';
// PrismaClient is attached to the `global` object in development to prevent
// exhausting your database connection limit.
//
// Learn more:
// https://pris.ly/d/help/next-js-best-practices
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma =
 globalForPrisma.prisma ||
 new PrismaClient({
 log: ['query'],
 });
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /