Homeglossary

Magic Link

Magic link is a passwordless authentication method that lets a user sign in by opening a unique, temporary URL sent to their email or phone. It replaces a remembered password with proof that the user can access the delivery channel, but its security depends on short expiry times, one-time use, and protecting that inbox or device.

Build passwordless apps with Emergent.

What Is a Magic Link?

A magic link is a passwordless authentication method that signs a user into an app or website through a unique, temporary URL sent to their email address or phone. It proves access to that inbox or device instead of requiring a remembered password. In software, a magic link is a login credential, not a marketing, affiliate, or private link.

How Magic Link Authentication Works

The link should work once, expire quickly, and create a session only after server-side validation.

  1. The user enters an email address or phone number and requests sign-in.
  2. The server generates a cryptographically secure random token tied to the account, expiry time, and purpose.
  3. The application sends a URL containing the token by email or another approved channel.
  4. The user opens the link, potentially on a different device.
  5. The server confirms the token is valid, unexpired, unused, and tied to a safe return address, then marks it used and starts a session.

Magic Links vs. One-Time Passwords

Both methods avoid stored passwords, but users prove access differently.

FactorMagic linkOne-time password
User actionOpen a URLCopy or type a code
Cross-device useCan cause browser or device mismatchUsually easier to enter on another device
Forwarding riskA forwarded link may grant accessA shared code may grant access
Best fitLow-friction email sign-inFlows where manual code entry is practical

Benefits of Magic Links

Magic links simplify access, but do not guarantee account safety.

  • They remove the need to create, remember, and reset passwords.
  • They reduce exposure to password reuse across services.
  • They support quick sign-up and returning-user access.
  • They can reduce forgotten-password support requests.

Practical Limits of Magic Links

The delivery channel becomes part of the security boundary.

  • Email can be delayed, filtered as spam, or unavailable offline.
  • Anyone with a shared or compromised inbox may use the link.
  • Forwarded links can expose an account while valid.
  • Email security scanners may open a link before its recipient.
  • A different browser can interrupt the expected sign-in flow.

How to Implement Magic Links Securely

A secure design treats each link as a short-lived credential.

  • Generate high-entropy random tokens and store a token hash where appropriate.
  • Set a short expiry and enforce one-time server-side use.
  • Rate-limit requests and avoid revealing whether an account exists.
  • Use HTTPS and validate redirect destinations against an allowlist.
  • Require stronger authentication for payments, account recovery, and other sensitive actions.

Using Magic Links in Apps Built With Emergent

Builders can specify passwordless sign-in, email delivery, secure redirects, and test cases as requirements. An AI app builder can turn them into an authentication flow, while Emergent's AI web app builder supports building, testing, and deploying the web application. Build passwordless apps with Emergent.

Start Building
on Emergent today
Start Building