Overview
createEmailTemplates returns a renderer for six pre-built HTML email templates (verification, password reset, magic link, email OTP, invitation, and welcome). render(name, vars) produces a { subject, text, html } object you pass to your mail provider.
Setup
appName appears in the subject lines and the email header and footer. appUrl is used for the default verification and reset links and for the welcome email button.
Built-in templates
When
verifyUrl or resetUrl is missing, the template builds {appUrl}/verify?token={token} or {appUrl}/reset-password?token={token}. Missing variables become empty strings, so check you pass what the template needs.
Using a template
render(name, vars) takes the template name and a flat map of string variables and returns { subject, text, html }.
Template expiry text
The expiry sentence in each template is fixed text, it does not read your configuration: verification says 24 hours, password reset says 1 hour, magic link says 15 minutes (matching the magic link default), and email OTP says 10 minutes. The email OTP module expires codes after 5 minutes by default, so either setcodeExpiry: 600 or provide an override with matching text.
Integrating with auth modules
The magic link and email OTP modules take a send callback and leave delivery to you. Pass template output to your mail provider inside it.- Magic link
- Email OTP
- Password reset
Customizing templates
Override any template with thetemplates option. Each override is a function that receives the same vars map as the built-in and must return { subject, text, html }.
Overrides only replace the templates you provide. All other templates continue to use the defaults.
Next steps
Magic link
Passwordless auth via email links.
Email OTP
One-time passcodes delivered by email.
Internationalization
Locale and message helpers.