Blogs
Feb 19, 2025
Learn how to use a custom email provider for sending Auth.js magic link emails. Step by step guide with code examples for Node.js, Next.js and TypeScript.
Motivation
Auth.js comes integrated with a set of email providers for sending magic link emails. However, you may want to heavily customize the magic link email behaviour in scenarios such as:
Using an email provider not supported by Auth.js
Customizing the email template beyond the default options
Implementing custom logic, e.g. sending SMS instead of emails
Tracking email delivery and engagement
Managing templates without code changes
Prerequisites
An email provider
We are biased, but we recommend NotificationAPI
Implementation
Auth.js allows you to customize the magic link email sending process through the sendVerificationRequest
function.
When a user requests a magic link, Auth.js generates a Magic Link and will call the sendVerificationRequest
function with the magic link or url
, along with the user's email address or identifier
. You can then use any email service to handle sending the email yourself.
Here's how to implement it with NotificationAPI:
Install the NotificationAPI SDK:
Don't forget to include the secrets of your favorite email provider in .env files:
Use the
sendVerificationRequest
function to send emails using your favorite email provider. We are using NotificationAPI in this example:
Where is the email template?
With NotificationAPI, you can visually design email templates in a user-friendly dashboard and use them inside your code. In the above example, we referenced the "magic_link" template, which we already designed in the dashboard:

Using Other Providers
You can adapt the same pattern for any email service:
For a complete working example, check out our example repository.