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 EmailPassword from "supertokens-node/recipe/emailpassword";
SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    supertokens: {        connectionURI: "...",    },    recipeList: [        EmailPassword.init({            override: {                apis: (originalImplementation) => {                    return {                        ...originalImplementation,
                        // here we only override the sign up API logic                         signUpPOST: async function (input) {
                            if (originalImplementation.signUpPOST === undefined) {                                throw Error("Should never come here")                            }                            // TODO: some custom logic
                            // or call the default behaviour as show below                            return await originalImplementation.signUpPOST(input);                        },                        // ...                        // 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 signUpPOST api of this recipe. This api will be called when the user clicks the sign up button on the frontend.
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react