Skip to content

Email link authentication

Also known as magic link, email authentication is a passwordless flow where users click a unique link sent to their email address to log in.

Add the np-login input component

DescriptionOverview
From your login page, just add the <np-login> component.

Once the user has entered their email address and validated it, an authentication email is sent to the entered address. By clicking on the received authorization link, he will be redirected to the original page with an extra code parameter. This component will then use it to create the user session and emits a np:login event.

const el = document.querySelector("np-login");
el.addEventListner("np:login", async (e) => {
// a session has been created 🎉
const { expires_at, token } = await e.target.getSession();
});

You are done!

Once the session established, you only have to transmit the session token to your server and verify it.