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 Session from "supertokens-node/recipe/session";

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

// here we are only overriding the function that signs out a user
signOutPOST: async function (input) {

if (originalImplementation.signOutPOST === undefined) {
throw Error("Should never come here")
}
// TODO: some custom logic

// or call the default behaviour as show below
return await originalImplementation.signOutPOST(input);
},
// ...
// TODO: override more apis
}
}
}
})
]
});
  • originalImplementation is the object that contains apis that have the original implementation for this recipe. It can be used in your apis as a way to use the SuperTokens' default behaviour.
  • In the above code snippet, we override the signOutPOST api of this recipe.
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react