Customizing Emails by Language

Last edited: 2/4/2025

When you register a user, you can create meta-data about them.

Creating meta-data with the JS-Client's signUp function

1
2
3
4
5
6
7
8
9
10
11
const { data, error } = await supabase.auth.signUp({ email: 'email@some_[email.com](http://email.com/)', password: 'example-password', options: { data: { first_name: 'John', last_name: 'Doe', age: 27, }, },})

The above example creates a user entry that includes information about their name and age. The data is stored in the auth.users table in the auth.raw_user_meta_data column. You can view it in the auth schema with the SQL Editor.

It can be accessed in a project's Email Templates. Below is an example:

image

If you need to update a user's meta-data, you can do so with the updateUser function.

The meta-data can be used to store a users language preferences. You could then use "if statements" in the email template to set the response for a specific language:

1
2
3
4
5
6
7
{{if eq .Data.langauge "en" }}<h1>Welcome!</h1>{{ else if eq .Data.langauge "pl" }}<h1>Witamy!</h1>{{ else }}<h1>chuS'ugh, tera' je (Klingon)</h1>{{end}}

Supabase uses the Go Templating Language to render emails. It has advanced features for conditions that you may want to explore. For more examples, there is a GitHub discussion that discusses advanced language templates.