[GH-ISSUE #870] Callback to run after successful emailVerification #8474

Closed
opened 2026-04-13 03:33:15 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @firatciftci on GitHub (Dec 12, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/870

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
The sendVerificationEmail() function is super useful for streamlining the email verification process. That said, I believe there is need for expanding the emailVerification object inside betterAuth() so that we can tie in more of custom logic to email verification. More specifically, there are certain fields that I would like to execute after the user verifies their email address via database calls. This could look like the following:

// auth.ts
import { betterAuth } from 'better-auth';

export const auth = betterAuth({
  emailVerification: {
    sendVerificationEmail: async ({ user, url, token ), request) => {
      // verification email logic here
    },
    // proposed callback function
    afterVerification: async ({ user, url, token }, request) => {
      // allow for any custom logic here
    },
  }
});

Describe alternatives you've considered
I have considered using webhooks to take care of this, and I believe it is the only viable/easy option to handle something like this, but having this natively available in the package would be a much better option in my opinion.

Additional context
I run the sendVerificationEmail() function with sendOnSignUp: true.

Originally created by @firatciftci on GitHub (Dec 12, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/870 **Is your feature request related to a problem? Please describe.** N/A **Describe the solution you'd like** The `sendVerificationEmail()` function is super useful for streamlining the email verification process. That said, I believe there is need for expanding the `emailVerification` object inside `betterAuth()` so that we can tie in more of custom logic to email verification. More specifically, there are certain fields that I would like to execute after the user verifies their email address via database calls. This could look like the following: ```typescript // auth.ts import { betterAuth } from 'better-auth'; export const auth = betterAuth({ emailVerification: { sendVerificationEmail: async ({ user, url, token ), request) => { // verification email logic here }, // proposed callback function afterVerification: async ({ user, url, token }, request) => { // allow for any custom logic here }, } }); ``` **Describe alternatives you've considered** I have considered using webhooks to take care of this, and I believe it is the only viable/easy option to handle something like this, but having this natively available in the package would be a much better option in my opinion. **Additional context** I run the `sendVerificationEmail()` function with `sendOnSignUp: true`.
GiteaMirror added the lockedenhancement labels 2026-04-13 03:33:15 -05:00
Author
Owner

@BrahimAkar commented on GitHub (Apr 12, 2025):

+1

<!-- gh-comment-id:2798836763 --> @BrahimAkar commented on GitHub (Apr 12, 2025): +1
Author
Owner

@iatomic1 commented on GitHub (Jun 9, 2025):

+1

<!-- gh-comment-id:2955690308 --> @iatomic1 commented on GitHub (Jun 9, 2025): +1
Author
Owner

@iatomic1 commented on GitHub (Jun 9, 2025):

@Bekacru can we get this really need it

<!-- gh-comment-id:2955691107 --> @iatomic1 commented on GitHub (Jun 9, 2025): @Bekacru can we get this really need it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8474