Pre / Post Hooks / Override
We provide you functionality to run code before and after an SMS is sent. You can use this for:
- Logging purposes
- Spam protection purposes
- Modifying the SMS template variables before sending the SMS
import supertokens from "supertokens-node";
import Passwordless from "supertokens-node/recipe/passwordless";
import Session from "supertokens-node/recipe/session";
supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
flowType: "USER_INPUT_CODE",
contactMethod: "PHONE",
smsDelivery: {
override: (originalImplementation) => {
return {
...originalImplementation,
sendSms: async function (input) {
// TODO: before sending SMS
await originalImplementation.sendSms(input)
// TODO: after sending SMS
}
}
}
},
}),
Session.init()
]
});