Next.js Discord

Discord Forum

NextAuth // Prisma | Email login requires an adapter

Unanswered
Lazyllama posted this in #help-forum
Open in Discord
I'm trying to setup a little self project and I'm using NextAuth V5 for authentication and prisma as database adapter. To get around the edge runtime stuff i used their guide and split my auth.ts file into two as per the docs. But, when i add Mailgun as a provider to get magiclinks it i need a database adapter even though its working fine for saving data and sessions and such. I suppose this an issue with the split config thing but not sure. Maybe someones smarter than me or have had this issue before and can give me some tips. Cheers.

auth.config.ts
import GitHub from "next-auth/providers/github"
import Mailgun from "next-auth/providers/mailgun"
import type { NextAuthConfig } from "next-auth"

export default {
    providers: [
        GitHub, 
        Mailgun
    ],
} satisfies NextAuthConfig


auth.ts
import NextAuth from "next-auth"
import authConfig from "./auth.config"

import { PrismaClient } from "@prisma/client"
import { PrismaAdapter } from "@auth/prisma-adapter"

const prisma = new PrismaClient()

export const { handlers, auth, signIn, signOut } = NextAuth({
    adapter: PrismaAdapter(prisma),
    session: { strategy: "jwt" },
    pages: {
        signIn: "/auth/signin",
    },
    ...authConfig,
})


Error
[auth][error] MissingAdapter: Email login requires an adapter. Read more at https://errors.authjs.dev#missingadapter
    at assertConfig (webpack-internal:///(middleware)/./node_modules/next-auth/node_modules/@auth/core/lib/utils/assert.js:141:24)
    at Auth (webpack-internal:///(middleware)/./node_modules/next-auth/node_modules/@auth/core/index.js:91:95)

0 Replies