SupabaseS
Supabase11mo ago
RedEye

Generate magic link in PostgreSQL function

Hey! I want to send users a custom email with an action button (e.g., "Confirm" or "Open") that:

  • Automatically logs them in when clicked
    (The below ones I have already figured out)
  • Records their action
  • Redirects to confirmation
Current architecture:
  • Backend logic and Email templates are generated in supabase PostgreSQL functions
  • Frontend with SvelteKit(Javascript)
What I Need Help With:
Is it possible to generate a token/code (like a magic link) directly in PostgreSQL that I can include in the email to automatically log users in when they click the link? If not is there any other way to achieve this like switching to edge functions?

For example:
https://website.app/action?action_id=22&token=somethingToLoginTheUser

Any help or suggestions would be greatly appreciated! 🙏
Was this page helpful?