Backend Functions Override
Use the override config
info
See all the functions that can be overrided here
import SuperTokens from "supertokens-node";
import Session from "supertokens-node/recipe/session";
import ThirdParty from "supertokens-node/recipe/thirdparty";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
supertokens: {
connectionURI: "...",
},
recipeList: [
Session.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// here we are only overriding the function that's responsible
// for creating a new session
createNewSession: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return await originalImplementation.createNewSession(input);
},
// ...
// TODO: override more functions
}
}
}
}),
ThirdParty.init({
signInAndUpFeature: {
providers: [/* ... */]
},
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// here we are only overriding the function that's responsible
// for signing in or signing up a user.
signInUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return await originalImplementation.signInUp(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
originalImplementation
is an object that contains 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
signInUp
function of this recipe. This function will be used to handle the scenario where a user either signs up or signs in via any third party provider.