JavaScript: Generate an email link

Generates email links and OTPs to be sent via a custom email provider.

Parameters

Examples

Generate a signup link

const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'signup',
  email: 'email@example.com',
  password: 'secret'
\})

Generate an invite link

const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'invite',
  email: 'email@example.com'
\})

Generate a magic link

const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'magiclink',
  email: 'email@example.com'
\})

Generate a recovery link

const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'recovery',
  email: 'email@example.com'
\})

Generate links to change current email address

// generate an email change link to be sent to the current email address
const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'email_change_current',
  email: 'current.email@example.com',
  newEmail: 'new.email@example.com'
\})

// generate an email change link to be sent to the new email address
const \{ data, error \} = await supabase.auth.admin.generateLink(\{
  type: 'email_change_new',
  email: 'current.email@example.com',
  newEmail: 'new.email@example.com'
\})