Short answer
A magic link is a one-time sign-in link sent by e-mail: clicking it proves the user controls the inbox and logs them in without a password. In Supabase, signInWithOtp sends one by default; each link works once and expires after an hour by default. The risks sit in where the link sends the user afterwards and in who may request links for which address.
Ask an AI about this page:ChatGPTClaude
On this page
A magic link is a one-time sign-in link sent to a user’s e-mail address: opening it proves they control that inbox and signs them in without a password. Supabase sends one when your app calls supabase.auth.signInWithOtp({ email }), unless you change the e-mail template to send a six-digit code instead. Supabase documents that each link works only once and that links expire after one hour by default.
Magic links in an AI-built app
Magic links are a popular choice for apps built with Lovable or Bolt because there is no password form, no reset flow and no password to leak. Three settings decide whether the flow is safe:
- Where the link leads. The app passes
emailRedirectTo, and Supabase only accepts your Site URL and the Additional Redirect URLs as destinations. A redirect list with broad**patterns in production, or a callback page that forwards to a?next=parameter without checking it, can send a freshly signed-in user somewhere else. - Who can sign up.
signInWithOtpcreates an account for unknown addresses by default. For an invite-only app, setshouldCreateUser: false. - How often links can be sent. Supabase limits how often one user can request a link (once per 60 seconds by default) and how many e-mails the built-in provider sends per hour. A custom endpoint that sends links through your own mail service has none of these limits unless you add them.
If the app uses the PKCE flow, the link must be opened in the browser that requested it, and the e-mail template sends a token hash that your /auth/confirm route verifies.
How to check your app
- Find every call to
signInWithOtpand read theemailRedirectTovalue. It should be a fixed URL on your own domain, not something built from the current URL or a query parameter. - In Authentication → URL Configuration, check that production redirect URLs are exact paths.
- Open the page the link lands on. If it reads
next,redirectorreturnTofrom the URL, check that it only navigates to same-origin paths. - Decide whether new sign-ups by magic link are wanted. If not, set
shouldCreateUser: false. - If you send links from your own edge function, add a rate limit per address and per IP.
How to prevent problems
Keep redirect targets fixed and on your domain, verify the link on a dedicated confirm route, and leave link expiry at the default unless you have a reason; Supabase advises against going above one day. The same redirect mistake appears in reset e-mails: see Password reset link that redirects to any URL. Confirmation, reset and redirect settings together are covered in Supabase Auth pitfalls.
Frequently asked questions
Is a magic link more secure than a password?
It removes weak and reused passwords, which takes credential stuffing off the table. In exchange, the e-mail inbox becomes the key to the account, so its security matters as much as a password did.
Why does a magic link sometimes fail on mobile?
Two common reasons: an e-mail scanner or link preview opened it first, and each link works only once; or the app uses PKCE and the link is opened on a different device or browser than the one that requested it.
Can anyone create an account by requesting a magic link?
By default, yes: signInWithOtp creates the user if they don’t exist. Set shouldCreateUser to false if only existing users may sign in this way.
Sources
- 1.Passwordless email logins — Supabase Docs
- 2.Redirect URLs — Supabase Docs
- 3.Rate limits — Supabase Docs
- 4.PKCE flow — Supabase Docs