Skip to main content

Handle Event Hook

This function is called for various user actions. It can be used for logging, analytics or any side effect purposes (these are essentially fire and forget events).

import Passwordless from "supertokens-auth-react/recipe/passwordless";
Passwordless.init({    contactMethod: "EMAIL", // This example works with any contactMethod    onHandleEvent: (context) => {        if (context.action === "PASSWORDLESS_CODE_SENT") {
        } else if (context.action === "PASSWORDLESS_RESTART_FLOW") {                    } else if (context.action === "SESSION_ALREADY_EXISTS") {            // called when a user visits the login / sign up page with a valid session            // in this case, they are usually redirected to the main app        } else if (context.action === "SUCCESS") {            let user = context.user;            if (context.isNewUser) {                // sign up success            } else {                // sign in success            }        }    },})
info
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react