Skip to main content

How to use

Use the override config#

SuperTokens.init({    appInfo: {...},    recipeList: [        EmailPassword.init({            override: {                functions: (originalImplementation) => {                    return {                        ...originalImplementation,
                        // we will only be overriding what happens when a user                        // clicks the sign in button.                        signIn: async (input) => {                            // TODO: some custom logic
                            // or call the default behaviour as show below                            return originalImplementation.signIn(input);                        },                        // ...                        // TODO: override more functions                    }                },                emailVerification: {                    functions: (originalImplementationEmailVerification) => {                        return {                            ...originalImplementationEmailVerification,                            isEmailVerified: async (input) => {                                // TODO: some custom logic
                                // or call the default behaviour as show below                                return originalImplementationEmailVerification.isEmailVerified(input);                            },                            // ...                            // TODO: override emailverification functions here                        }                    }                }            }        })    ]});
  • 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 signIn function of this recipe. This means that when the user clicks the sign in button in the UI, your function will be called with the relevant input object.
  • Likewise, we override the isEmailVerified function for the email verification recipe. This means that when a user signs in / up, and if email verification is in "REQUIRED" mode, then your function will be called to check if that user's email is verified or not.