feat: add email templates and email OTP login flow #2110
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a comprehensive email template system powered by React Email and significantly enhances the authentication experience with modern login methods including passkeys, social auth, and OTP verification. Also, fixes outdated docs mentioned in #2108.
Key Features
🎨 React Email Template System
A new
@repo/email
package provides beautiful, responsive transactional email templates:🔐 Modern Authentication Methods
Enhanced login experience with multiple authentication options:
📧 Email Service Integration
Complete email sending infrastructure via Resend API:
Getting Started
Email Development
Environment Setup
Add these variables to your
.env
:Using Email Templates
Architecture Changes
Modular Authentication Components
The login system is now split into focused, reusable components:
PasskeyLogin
- Handles WebAuthn authentication with autofill supportSocialLogin
- Manages OAuth provider flowsOtpVerification
- Processes email OTP codesuseLoginForm
- Centralized hook for form logic and state managementEmail Service Architecture
API Integration
The API layer now includes:
lib/email.ts
Testing Instructions
Email Templates
bun email:dev
to preview all templatesAuthentication Flows
Error Scenarios
Breaking Changes
None - all changes are backwards compatible. Existing password-based authentication continues to work alongside new methods.
Performance Considerations
Security Enhancements
Documentation Updates
Dependencies
@react-email/components
- Email component libraryresend
- Email delivery servicebetter-auth/plugins/email-otp
- OTP authenticationbetter-auth/plugins/passkey
- WebAuthn supportDeployment Notes
Before deploying:
bun email:build
Future Enhancements