© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago
Cheqo

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"
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"
refered_by: "abcd"


But, what if they use magic link? when they confirm the email it takes them back to
myapp.com
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() }
    );
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
GitHub - vercel/nextjs-subscription-payments: Clone, deploy, and fu...
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...
GitHub - vercel/nextjs-subscription-payments: Clone, deploy, and fu...
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Magic Link Redirect URL in Email confusion
SupabaseSSupabase / help-and-questions
2mo ago
magic link login with flutter
SupabaseSSupabase / help-and-questions
4y ago
Magic Link 403
SupabaseSSupabase / help-and-questions
6mo ago
Magic link email
SupabaseSSupabase / help-and-questions
4y ago