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-node";
import Passwordless from "supertokens-node/recipe/passwordless";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", // This example will work with any flow.

override: {
functions: (originalImplementation) => {
return {
...originalImplementation,

// here we are only overriding the function that's responsible
// for signing in / up a user.
consumeCode: async function (input) {
// TODO: some custom logic

// or call the default behaviour as show below
return await 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 function of this recipe. This function will be used to handle the scenario when the user enters an OTP or clicks on a magic link.
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI