Skip to main content

How to use

Use the override config#

SuperTokens.init({    appInfo: {...},    supertokens: {...},    recipeList: [        EmailPassword.init({            override: {                functions: (originalImplementation) => {                    return {                        ...originalImplementation,
                        // here we are only overriding the function that's responsible                        // for signing in a user.                        signUp: async (input) => {                            // TODO: some custom logic
                            // or call the default behaviour as show below                            return await originalImplementation.signUp(input);                        },                        // ...                        // TODO: override more functions                    }                },                emailVerificationFeature: {                    functions: (originalImplementationEmailVerification) => {                        return {                            ...originalImplementationEmailVerification,                            isEmailVerified: async (input) => {                                // TODO: some custom logic
                                // or call the default behaviour as show below                                return await originalImplementationEmailVerification.isEmailVerified(input);                            },                            // ...                            // TODO: override more functions                        }                    }                }            }        })    ]});
  • originalImplementation and originalImplementationEmailVerification are objects that contain functions that have the original implementation for this and the email verification 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 signUp function of this recipe. This function will be used to handle the scenario when the user clicks on the sign up button from the frontend.
  • Likewise, we override the isEmailVerified function for the email verification recipe.