1. HelpDesk
  2. Developer FAQ

Can I redirect to my site after a user clicks the magic link?

The redirect URI is supported in Magic starting with magic-sdk version <2.6.0>.

Pass in a <redirectURI> parameter to <loginWithMagicLink> which is where the user will get redirected to after clicking the magic link.

const did = await magic.auth.loginWithMagicLink({ 
redirectURI: `${window.location.origin}/callback`

On the redirect page, call <await magic.auth.loginWithCredential();> which will grab and return the DID token from the query parameters which you can then send to your backend to validate.

Check out our example app showing how it works.