Handling signup success
There are multiple reasons why you would like to get notified about a successful Signup.
Redirect to a specific URL
SuperTokens.init({
appInfo: {...},
recipeList: [
EmailPassword.init({
getRedirectionURL (context) {
if (context.action === "SUCCESS") {
return "/dashboard";
}
}
}),
Session.init()
]
});
The user will be redirected to the provided URL on:
- Successful sign up
- Successful sign in
- Successful email verification.
- If the user is already logged in.
This is useful in the following cases:
- Custom routing based on who signed up (useful for multi tenancy scenarios)
- Custom routing based on AB Testing
Please refer to the auth-react reference API for more information on getRedirectionURL
hook.
Store analytics events
This method allows you to have much more control of events that occur immediately after a successful sign up:
- Registering a user to an analytics service
- Sending analytics events post sign up
SuperTokens.init({
appInfo: {...},
recipeList: [
EmailPassword.init({
onHandleEvent = async (context) => {
if (context.action === "SESSION_ALREADY_EXISTS") {
// TODO:
} else {
let {id, email} = context.user;
if (context.action === "SIGN_IN_COMPLETE") {
// TODO:
} else {
// context.action === "SIGN_UP_COMPLETE"
// TODO:
}
}
}
}),
Session.init()
]
});
Please refer to the auth-react reference API for more information on onHandleEvent
hook.