Preserving url params with magic link

Hello, I am using this supabase template - https://github.com/vercel/nextjs-subscription-payments

I wanted to know sign up referrals, to track media or users conversion results.

So, I thought of attaching referral code to my landing page like this - myapp.com/?ref="abc"

I can simply grab this code and when user creates account, I make a call to public users table and attach a value like: refered_by: "abcd"

But, what if they use magic link? when they confirm the email it takes them back to myapp.com ? or can I set it, so that it goes back to a link with a reference code on it?

Here is some that is used with this template.

const getURL = () => {
  const url =
    process?.env?.URL && process.env.URL !== ''
      ? process.env.URL
      : process?.env?.VERCEL_URL && process.env.VERCEL_URL !== ''
      ? process.env.VERCEL_URL
      : 'http://localhost:3000';
  return url.includes('http') ? url : `https://${url}`;
};

    const { error } = await supabaseClient.auth.signIn(
      { email, password },
      { redirectTo: getURL() }
    );


Does this preserve the query params? or do I need to do something else?
GitHub
Clone, deploy, and fully customize a SaaS subscription application with Next.js. - GitHub - vercel/nextjs-subscription-payments: Clone, deploy, and fully customize a SaaS subscription application w...
Was this page helpful?