Next.js Discord

Discord Forum

auth.js middleware

Answered
Pyramid ant posted this in #help-forum
Open in Discord
Pyramid antOP
Hello, when i created a middleware i got this error:

[auth][error] MissingAdapter: Email login requires an adapter. Read more at https://errors.authjs.dev#missingadapter
    at assertConfig (C:\Users\wvn_0\Desktop\project\my-app\.next\server\edge\chunks\node_modules_@auth_core_d0be13._.js:657:34)
    at Auth (C:\Users\wvn_0\Desktop\project\my-app\.next\server\edge\chunks\node_modules_@auth_core_d0be13._.js:5193:202)



How can i fix it.. I looked at the web nothing was there
Answered by Pyramid ant
but i fixed it somehow... i used this:

auth.ts:

import NextAuth from "next-auth"
import authConfig from "../../auth.config"
 
export const { handlers, signIn, signOut, auth } = NextAuth({
  ...authConfig
})


auth.config.ts:

import Resend from "next-auth/providers/resend"
import { PrismaAdapter } from "@auth/prisma-adapter"
import { prisma } from "./src/utils/db" // Adjust path if needed
import type { NextAuthConfig } from "next-auth"

export default {
  adapter: PrismaAdapter(prisma),
  session: { strategy: "jwt" },
  providers: [
    Resend({
      from: "no-reply@domain.com",
    }),
  ],
  secret: process.env.AUTH_SECRET, // Ensure this is set in your .env file
  pages: {
    signIn: "/signin",
    signOut: "/signout",
    newUser: "/",
  },
} satisfies NextAuthConfig;
View full answer

19 Replies

Pyramid antOP
I have adapter
show
Pyramid antOP
But it dont detect
Pyramid antOP
but i fixed it somehow... i used this:

auth.ts:

import NextAuth from "next-auth"
import authConfig from "../../auth.config"
 
export const { handlers, signIn, signOut, auth } = NextAuth({
  ...authConfig
})


auth.config.ts:

import Resend from "next-auth/providers/resend"
import { PrismaAdapter } from "@auth/prisma-adapter"
import { prisma } from "./src/utils/db" // Adjust path if needed
import type { NextAuthConfig } from "next-auth"

export default {
  adapter: PrismaAdapter(prisma),
  session: { strategy: "jwt" },
  providers: [
    Resend({
      from: "no-reply@domain.com",
    }),
  ],
  secret: process.env.AUTH_SECRET, // Ensure this is set in your .env file
  pages: {
    signIn: "/signin",
    signOut: "/signout",
    newUser: "/",
  },
} satisfies NextAuthConfig;
Answer
are you sure it connects to prisma?
@Diamond Master are you sure it connects to prisma?
Pyramid antOP
Its fixed alredy
oh
what was the error?
ah
idk then
how was the code before that
Pyramid antOP
I dont know. I rewrited it alredy
ah ok
mark it as a solution
perfect