© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago•
62 replies
Revadike

[Nuxt] Login flow with magic link

For some reason, I can't make the magic link work.
I have a nuxt 3 project with @nuxtjs/supabase module.
I run
supabase start && supabase functions serve
supabase start && supabase functions serve

I have an edge function
login
login
that does the following:
import { createClient } from "jsr:@supabase/supabase-js@2";

Deno.serve(async () => {
  const supabase = createClient(
    Deno.env.get("SUPABASE_URL") ?? "",
    // Deno.env.get("SUPABASE_ANON_KEY") ?? "",
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
  );

  const email = "email@example.com";

  const { data, error } = await supabase.auth.admin.generateLink({
    type: "magiclink",
    email,
    options: {
      redirectTo: "http://localhost:3000/confirm",
    },
  });

  console.log({ data, error });

  return new Response(
    JSON.stringify({
      url: `${data?.properties?.action_link}/confirm&email=${
        encodeURIComponent(email)
      }`,
    }),
    { headers: { "Content-Type": "application/json" } },
  );
});
import { createClient } from "jsr:@supabase/supabase-js@2";

Deno.serve(async () => {
  const supabase = createClient(
    Deno.env.get("SUPABASE_URL") ?? "",
    // Deno.env.get("SUPABASE_ANON_KEY") ?? "",
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? "",
  );

  const email = "email@example.com";

  const { data, error } = await supabase.auth.admin.generateLink({
    type: "magiclink",
    email,
    options: {
      redirectTo: "http://localhost:3000/confirm",
    },
  });

  console.log({ data, error });

  return new Response(
    JSON.stringify({
      url: `${data?.properties?.action_link}/confirm&email=${
        encodeURIComponent(email)
      }`,
    }),
    { headers: { "Content-Type": "application/json" } },
  );
});


when I generate a magic link and open it on my nuxt 3 application, I don't get logged in automatically. This is what supposed to happen, right?
user
user
from
useSupabaseUser
useSupabaseUser
remains
null
null
.

Here is
confirm.vue
confirm.vue
:
<script setup>
  const user = useSupabaseUser();

  watch(() => user.value, () => {
    if (user.value) {
      navigateTo('/');
    }
  });
</script>

<template>
  <div>
    Redirecting...
  </div>
</template>
<script setup>
  const user = useSupabaseUser();

  watch(() => user.value, () => {
    if (user.value) {
      navigateTo('/');
    }
  });
</script>

<template>
  <div>
    Redirecting...
  </div>
</template>


I even added this to
config.toml
config.toml
:
additional_redirect_urls = ["https://127.0.0.1:3000","http://127.0.0.1:3000/inloggen","http://127.0.0.1:3000/confirm"]
additional_redirect_urls = ["https://127.0.0.1:3000","http://127.0.0.1:3000/inloggen","http://127.0.0.1:3000/confirm"]
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 login with flutter
SupabaseSSupabase / help-and-questions
4y ago
Magic Link 401 - NUXT
SupabaseSSupabase / help-and-questions
3y ago
Discourse SSO with Supabase Magic Link login
SupabaseSSupabase / help-and-questions
4y ago
Self-hosted SB magic link login with SMTP
SupabaseSSupabase / help-and-questions
2w ago
Next page