signUp on server-side not sending sendVerificationEmail()

Since the changes in v0.4.12 (though I’m not 100% sure), sendVerificationEmail() is no longer triggered automatically when I call auth.api.signUpEmail(). Next.js Server-Action:
await auth.api.signUpEmail({
body: {
email,
password,
name,
callbackURL: "/auth/login",
},
asResponse: true,
});
...
await auth.api.signUpEmail({
body: {
email,
password,
name,
callbackURL: "/auth/login",
},
asResponse: true,
});
...
auth.ts:
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
...
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
},
emailVerification: {
sendOnSignup: true,
sendVerificationEmail: async (user, url) => {
console.log("Sending verification email to", user.email);
await sendVerificationEmailNodemailer(user.email, url);
},
},
...
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
...
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
},
emailVerification: {
sendOnSignup: true,
sendVerificationEmail: async (user, url) => {
console.log("Sending verification email to", user.email);
await sendVerificationEmailNodemailer(user.email, url);
},
},
...
Yes, I can manually call sendVerificationEmail() in my server action but I don’t think that’s the intended way to handle this:
await auth.api.sendVerificationEmail({
body: { email, callbackURL: "/auth/login" },
asResponse: true,
});
await auth.api.sendVerificationEmail({
body: { email, callbackURL: "/auth/login" },
asResponse: true,
});
5 Replies
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
future42
future42OP5mo ago
Ok, I think this is important information because the demo site uses the client library.
bekacru
bekacru5mo ago
The demo works, but it's not sending on signup because the auth config hasn't been updated since the last changes. But @future42 try it with the latest version and let me know if it's still an issue. this could be cause of resend, I'll check.
future42
future42OP5mo ago
Nope. With “better-auth”: “^0.5.2-beta.7”, it doesn't work.
future42
future42OP5mo ago
Ok we can close this issue. I have written the “Up” in lower case for sendOnSignUp: true.
// Package: sign-up.ts
if (ctx.context.options.emailVerification?.sendOnSignUp) {
...
// Package: sign-up.ts
if (ctx.context.options.emailVerification?.sendOnSignUp) {
...
The Docs are wrong: https://www.better-auth.com/docs/concepts/email#1-during-sign-up i create an PR on Github: Fix typo: corrected capitalization issue. #263
Email | Better Auth
Learn how to use email with Better Auth.

Did you find this page helpful?