JavaScript: generateLink | Supabase Docs

JavaScript: generateLink

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

Parameters

  • params

    (Required)

    The parameters for generating the link, including the link `type`, the user's `email`, and type-specific options such as `password`, `data`, and `redirectTo`.

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'
})