Skip to main content

If you are using our backend SDK that is lesser than the following versions, please visit the older documentation link here.

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 ThirdParty from "supertokens-auth-react/recipe/thirdparty";
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";

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

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

} else if (context.action === "SUCCESS") {
if (context.createdNewSession) {
let user = context.user;
if (context.isNewRecipeUser && context.user.loginMethods.length === 1) {
// sign up success
} else {
// sign in success
}
} else {
// during step up or second factor auth with email password
}
}
}
})

ThirdParty.init({
onHandleEvent: (context) => {
if (context.action === "SUCCESS") {
if (context.createdNewSession) {
let user = context.user;
if (context.isNewRecipeUser && context.user.loginMethods.length === 1) {
// sign up success
} else {
// sign in success
}
} else {
// during linking a social account to an existing account
}
}
}
})
info
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI