Email Templates
This guide will help you set up and customize email templates for both transactional and marketing emails in the Next.js Supabase SaaS template using Supabase and Resend services.
Overview
In the Next.js Supabase SaaS template, email templates are used to send professional and consistent emails to users. Two key types of emails are managed in the template:
- Transactional Emails: Handled by Supabase, primarily for authentication-related actions.
- Marketing Emails: Managed via Resend, with email templates created using
React.Email
.
Transactional Emails (Supabase)
Supabase is used for all auth-related transactional emails. These emails include actions such as user invitations, password resets, and email change confirmations. Supabase provides a variety of pre-configured email templates that can be customized for your specific use case.
Supabase Email Templates
- Invite User
- Magic Link
- Change Email Address
- Reset Password
Customizing Email Templates Locally
To customize Supabase email templates for local development:
- Open the
config.toml
file located in the/supabase/templates
directory. - Specify the email subject and content path in the appropriate configuration section.
- Example configuration:
Customizing Supabase Email Templates in Production:
You can edit templates in Supabase dashboard (Similar to customizing templates locally)
- Open Supabase Dashboard and select project.
- Go to Authentication tab and Select Email Templates under Configuration column.
- Edit the templates. Refer Link (
https://supabase.com/dashboard/project/{project_id}/auth/templates
)
For detailed information on customizing Supabase email templates, refer to the official Supabase documentation.
Marketing Emails (Resend)
For marketing emails, the template uses the Resend service along with react.email
to create visually appealing and responsive email templates.
Setting Up Resend
Before you can start creating marketing email templates, ensure that you have set up your Resend account in the template. Detailed instructions for setting up Resend can be found here.
Marketing Email Template
To add a new marketing email template:
- Create a new template file in the
/emails
directory in root. - You can refer to the
invite.tsx
example for structuring your email template.
Below is a sample code snippet for an Invite Email Template:
In this example, the template dynamically references the application's name and email logo, providing a personalized experience for the user.