Steps to use magic links

  1. User enters email address on login page
  2. Supabase sends an email containing a unique, time-sensitive link to the user
  3. User clicks the link, redirects to the app and authenticates
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = 'https://your-project-url.supabase.co';
const supabaseKey = 'your-anon-key';
const supabase = createClient(supabaseUrl, supabaseKey);

// Send a magic link to the user's email
const { user, error } = await supabase.auth.signIn({
  email: 'user@example.com',
  options: {
    redirectTo: 'https://yourapp.com/callback', // URL to redirect after login
  },
});

if (error) {
  console.error('Error sending magic link:', error.message);
} else {
  console.log('Magic link sent successfully!');
}

From: The Coding Sloth - Cómo programar aplicaciones que generen DINERO INFINITO