Skip to main content

Pre / Post Hooks / Override

We provide you funtionality to run code before and after an email is sent. You can use this for:

  • Logging putposes
  • Spam protection purposes
  • Modifying the email template variables before sending the emails
import supertokens from "supertokens-node";import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";import Session from "supertokens-node/recipe/session";
supertokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    recipeList: [        ThirdPartyEmailPassword.init({            emailDelivery: {                override: (originalImplementation) => {                    return {                        ...originalImplementation,                        sendEmail: async function (input) {                            // TODO: run some logic before sending the email                                                        await originalImplementation.sendEmail(input);
                            // TODO: run some logic post sending the email                        }                    }                }            },        }),        Session.init()    ]});