Magic Link
Email-only sign-in via a one-click link.
Like passwordless OTP, but instead of a typed code the user clicks a link that contains the code as a query param.
Server config
Same passwordless config as the OTP flow — magic link is just a different delivery mechanism on the server side.
How it works
- Client calls
POST /auth/passwordless/sendwith{ identifier, channel: 'email' }. - The library emits
PasswordlessCodeRequestedEventwithcodeandidentifier. - Your listener constructs the magic link URL, embedding the code, and emails it. The library doesn't generate the URL because it doesn't know your frontend's domain or routing.
- User clicks the link, frontend reads the code from the URL, and calls
POST /auth/loginwith the passwordless credentials.
Listener (server)
Frontend route
In your React app, add a /auth/magic-link route that reads the query params and calls login:
Security notes
- Magic links are bearer tokens. Anyone with the URL can sign in. Use short expiry (
otp.codeExpiresIn: '10m') andhttpOnlycookies. - Don't log the URL or include it in error reports.
- The code can only be redeemed once — the next call to
/auth/loginwith the same code fails.
Related
- Passwordless OTP — typed-code variant.
- Sending Emails.