Which UI do you use?
Custom UI
Pre built UI
How to use
#
Use the override configinfo
See all the functions that can be overrided here
- ReactJS
- Angular
- Vue
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
supertokensUIInit("supertokensui", {
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
supertokensUIPasswordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// enters the OTP or clicks on the magic link
consumeCode: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.consumeCode(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
import SuperTokens from "supertokens-auth-react";
import Passwordless from "supertokens-auth-react/recipe/passwordless";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// enters the OTP or clicks on the magic link
consumeCode: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.consumeCode(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
supertokensUIInit("supertokensui", {
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
supertokensUIPasswordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// enters the OTP or clicks on the magic link
consumeCode: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.consumeCode(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
originalImplementation
is an object that contain functions that have the original implementation for this 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
consumeCode
function of this recipe. This means that when the user clicks enters the OTP or clicks on the magic link, your function will be called with the relevantinput
object.