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 ThirdPartyEmailPassword from "supertokens-auth-react/recipe/thirdpartyemailpassword";

ThirdPartyEmailPassword.init({
onHandleEvent: (context) => {
if (context.action === "PASSWORD_RESET_SUCCESSFUL") {

} else if (context.action === "RESET_PASSWORD_EMAIL_SENT") {

} 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.isNewRecipeUser && context.user.loginMethods.length === 1) {
// sign up success
} else {
// sign in success
}
}
}
})
info
Looking for older version of the documentation?
Which UI do you use?
Custom UI
Pre built UI