Skip to main content

How to use

If you would like to change something pre or post our API logic, then use this method.

import SuperTokens from "supertokens-node";
import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
supertokens: {
connectionURI: "...",
},
recipeList: [
ThirdPartyEmailPassword.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,

// here we only override the email & password sign up API logic
emailPasswordSignUpPOST: async function (input) {
if (originalImplementation.emailPasswordSignUpPOST === undefined) {
throw Error("Should never come here");
}

// TODO: some pre sign up logic

let response = await originalImplementation.emailPasswordSignUpPOST(input);

if (response.status === "OK") {
// TODO: some post sign up logic
}

return response;

},
// ...
// TODO: override more apis
}
}
}
})
]
});
  • originalImplementation is an object that contains apis that have the original implementation for this recipe. They can be used in your custom apis as a way to use the SuperTokens' default behaviour.
  • In the above code snippet, we override the emailPasswordSignUpPOST api of this recipe. This api will be used to handle the email password sign up requests.
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI