Why This Matters Now: With the increasing emphasis on user experience and security in digital platforms, integrating Resend with Auth0 provides a seamless and secure way to handle email delivery. The recent surge in email-related vulnerabilities underscores the importance of robust email infrastructure. As of March 2024, Resend has been integrated into Auth0, offering developers a powerful tool to enhance their email workflows.
Prerequisites
Before diving into the integration process, ensure you have the following set up in your Resend account:
Domain Verification
- Add Your Sending Domain: Go to the Resend dashboard and add your sending domain.
- Configure DNS Records: Follow the instructions provided by Resend to set up SPF, DKIM, and DMARC records. This ensures your emails are authenticated and less likely to be marked as spam.
API Key
- Generate an API Key: Navigate to the Resend dashboard, go to the API Keys section, and generate a new API key. This key will serve as both your SMTP password and a secret for Auth0 Actions.
Configuring Resend as an Email Provider
Option 1: Basic Configuration
For a quick setup, follow these steps to integrate Resend as your email provider in Auth0.
Dashboard Configuration
Navigate to Email Provider Settings:
- Go to your Auth0 Dashboard.
- Head to
Branding > Email Provider.
Enable Custom Email Provider:
- Toggle on
Use my own email provider. - Select
Resend.
- Toggle on
Enter Resend Credentials:
- Fill in the
API Keyfield with your Resend API key. - Set the
Fromaddress to match the domain you verified in Resend.
- Fill in the
Test the Configuration:
- Click
Send Test Emailto verify the setup. - Check your inbox and the Resend dashboard for the test email.
- Click
Troubleshooting Common Issues
- SMTP Errors: Check Auth0 Logs for SMTP errors. Common issues include port blocking (avoid port 25) and DNS propagation delays on newly verified domains.
🎯 Key Takeaways
- Quickly configure Resend as your email provider in Auth0.
- Ensure domain verification and correct API key usage.
- Test your configuration to avoid delivery issues.
Option 2: Using Auth0 Actions with the Resend SDK
For more control and customization, use Auth0 Actions with the Resend SDK.
Writing the Action
Create a New Action:
- Go to
Actions > Library. - Click
Create Actionand chooseCustom. - Enter a name and select a trigger (e.g., Post Login).
- Go to
Add Dependencies:
- In the left icons panel, click
Dependencies. - Click
Add Dependencyand typeresend, then clickAdd.
- In the left icons panel, click
Add Secrets:
- Click
Secretsand add your Resend API key asRESEND_API_KEY.
- Click
Write the Code:
- Use the following example code to send an email on user login:
const { Resend } = require('resend');
exports.onExecutePostLogin = async (event, api) => {
const resend = new Resend(event.secrets.RESEND_API_KEY);
if (event.stats.logins_count === 1) {
try {
await resend.emails.send({
from: 'Security <security@your_domain.com>',
to: event.user.email,
subject: 'New login detected',
html: `
<div style="font-family: sans-serif; padding: 20px;">
<h2>Security Alert</h2>
<p>Hi ${event.user.name || 'there'},</p>
<p>New login from IP: ${event.request.ip}</p>
<p>Not you? Reset your password.</p>
</div>
`,
tags: [{ name: 'category', value: 'security_alert' }],
});
} catch (error) {
console.error('Resend failed:', error);
}
}
};
- Deploy the Action:
- Go to
Actions > Triggers. - Select the
Post Logintrigger. - Drag your custom action into the flow and click
Deploy.
- Go to
Customizing Email Templates with Liquid and Resend’s React Email
Auth0 uses Liquid syntax for dynamic variables in email templates. You can edit these templates directly in the Auth0 Dashboard under Branding > Email Templates.
Edit Templates:
- Open the template you want to modify.
- Use Liquid syntax for dynamic content (e.g.,
{{ user.email }},{{ url }}).
Using React Email:
- Resend supports React Email components for building modern email templates.
- Integrate React Email components into your Auth0 templates for enhanced design and functionality.
🎯 Key Takeaways
- Gain full programmatic control with Auth0 Actions and Resend SDK.
- Customize email content and triggers based on user actions.
- Enhance email design with React Email components.
Conclusion
Integrating Resend with Auth0 offers a robust solution for email delivery, combining ease of use with advanced customization options. By following the steps outlined above, you can ensure your emails are delivered efficiently and securely, enhancing both user experience and security.

