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.

How to use

Use the override config#

import SuperTokens from "supertokens-auth-react";
import Passwordless from "supertokens-auth-react/recipe/passwordless";
import ThirdParty from "supertokens-auth-react/recipe/thirdparty";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
ThirdParty.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
signInAndUp: async function (input) {
// TODO: some custom logic

// or call the default behaviour as show below
return originalImplementation.signInAndUp(input);
},
// ...
// TODO: override more functions
}
}
}
}),
Passwordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// enters the OTP or clicks on the magic link
consumeCode: async function (input) {
// TODO: some custom logic

// or call the default behaviour as show below
return originalImplementation.consumeCode(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
  • originalImplementation is an object that contain functions that have the original implementation for this recipe. They can be used in your functions as a way to use the SuperTokens' default behaviour.
  • In the above code snippet, we override the consumeCode and the signinup function of the two recipes. This means that when the user clicks enters the OTP or clicks on the magic link or uses social login, your function will be called with the relevant input object.
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI