Local Development

Customizing email templates

Customizing local email templates using config.toml.


You can customize the email templates for local development using the config.toml settings.

Configuring templates

You should provide a relative URL to the content_path parameter, pointing to an HTML file which contains the template. For example

1
2
3
[auth.email.template.invite]subject = "You are invited to Acme Inc"content_path = "./supabase/templates/invite.html"

Available email templates

There are several Auth email templates which can be configured. Each template serves a specific authentication flow:

auth.email.template.invite

Default subject: "You have been invited" When sent: When a user is invited to join your application via email invitation Purpose: Allows administrators to invite users who don't have accounts yet Content: Contains a link for the invited user to accept the invitation and create their account

auth.email.template.confirmation

Default subject: "Confirm Your Signup" When sent: When a user signs up and needs to verify their email address Purpose: Email verification for new user registrations Content: Contains a confirmation link to verify the user's email address

auth.email.template.recovery

Default subject: "Reset Your Password" When sent: When a user requests a password reset Purpose: Password recovery flow for users who forgot their password Content: Contains a link to reset the user's password

Default subject: "Your Magic Link" When sent: When a user requests a magic link for passwordless authentication Purpose: Passwordless login using email links Content: Contains a secure link that automatically logs the user in when clicked

auth.email.template.email_change

Default subject: "Confirm Email Change" When sent: When a user requests to change their email address Purpose: Verification for email address changes Content: Contains a confirmation link to verify the new email address

auth.email.template.reauthentication

Default subject: "Confirm Reauthentication" When sent: When a user needs to re-authenticate for sensitive operations Purpose: Additional verification for sensitive actions (like changing password, deleting account) Content: Contains a 6-digit OTP code for verification

Template variables

The templating system provides the following variables for use:

ConfirmationURL

Contains the confirmation URL. For example, a signup confirmation URL would look like:

1
https://project-ref.supabase.co/auth/v1/verify?token={{ .TokenHash }}&type=email&redirect_to=https://example.com/path

Usage

1
<p>Click here to confirm: {{ .ConfirmationURL }}</p>

Token

Contains a 6-digit One-Time-Password (OTP) that can be used instead of the ConfirmationURL.

Usage

1
<p>Here is your one time password: {{ .Token }}</p>

TokenHash

Contains a hashed version of the Token. This is useful for constructing your own email link in the email template.

Usage

1
2
3
4
5
6
<p>Follow this link to confirm your user:</p><p> <a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email" >Confirm your email</a ></p>

SiteURL

Contains your application's Site URL. This can be configured in your project's authentication settings.

Usage

1
<p>Visit <a href="{{ .SiteURL }}">here</a> to log in.</p>

Email

Contains the user's email address.

Usage

1
<p>A recovery request was sent to {{ .Email }}.</p>

NewEmail

Contains the new user's email address. This is only available in the email_change email template.

Usage

1
<p>You are requesting to update your email address to {{ .NewEmail }}.</p>

Deploying email templates

These settings are for local development. To apply the changes locally, stop and restart the Supabase containers:

1
supabase stop && supabase start

For hosted projects managed by Supabase, copy the templates into the Email Templates section of the Dashboard.