How I can use Resend for next-auth email provider?
Unanswered
Common paper wasp posted this in #help-forum
Common paper waspOP
Nextjs 14, next-auth v5 (https://authjs.dev/). Trying to use email provider with resend but got
Can't resolve 'nodemailer' error, if I install this I will get another error as nodemailer is not compatible with edge. import Email from "next-auth/providers/email";
export const config = {
adapter: PrismaAdapter(prisma),
providers: [
Email({
sendVerificationRequest: async ({ identifier, url, provider }) => {
const user = await prisma.user.findUnique({
where: {
email: identifier,
},
select: {
name: true,
emailVerified: true,
},
});
const userVerified = user?.emailVerified ? true : false;
const authSubject = userVerified
? `Sign-in link for WishList`
: "Activate your account";
try {
await resend.emails.send({
from: "SaaS Starter App <onboarding@resend.dev>",
to:
process.env.NODE_ENV === "development"
? "delivered@resend.dev"
: identifier,
subject: authSubject,
react: `<p>Hello ${
user?.name
} here is your link ${url}. Mailtype is: ${
userVerified ? "login" : "register"
}</p>`,
// Set this to prevent Gmail from threading emails.
// More info: https://resend.com/changelog/custom-email-headers
headers: {
"X-Entity-Ref-ID": new Date().getTime() + "",
},
});
} catch (error) {
throw new Error("Failed to send verification email.");
}
},
}),
],1 Reply
Asiatic Lion
could you resolve this?