Search code examples
javascriptreactjsnext.jsvercelsupabase

Supabase Email Redirect


How can I make dynamic redirect link in confirmation email after user create account?

For example:

If some user gets to the web site using link www.website.com/project/1 or /project/2 etc. And it doesn't have account and needs to make one. After sign up, user needs to confirm account via email, after confirmation user gets redirected to www.website.com/ in a new tab.

How can I setup email dynamic redirect link to redirect the user to specific nested route?


Solution

  • You can pass the emailRedirectTo a full url to the page you want it to go to.

    await supabase.auth.signUp({ email, password, 
      options: {
        emailRedirectTo: 'http://example.com/project/1' // you will have to make the project part dynamic in whichever way the framework you are using allows you to do this.
      } 
    })
    

    You will also need to add these URLs to the Redirect URLs allow list. https://app.supabase.com/project/_/auth/url-configuration