Which UI do you use?
Custom UI
Pre built UI
How to use
#
Use the override config- ReactJS
- Angular
- Vue
info
See all the functions that can be overrided here
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
(window as any).supertokensUIInit("supertokensui", {
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
(window as any).supertokensUIEmailPassword.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign up button.
signUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signUp(input);
},
// ...
// TODO: override more functions
}
}
}
}),
(window as any).supertokensUIThirdParty.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign in or sign up button.
signInAndUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signInAndUp(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
info
See all the functions that can be overrided here
import SuperTokens from "supertokens-auth-react";
import ThirdParty from "supertokens-auth-react/recipe/thirdparty";
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
EmailPassword.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign up button.
signUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signUp(input);
},
// ...
// TODO: override more functions
}
}
}
}),
ThirdParty.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign in or sign up button.
signInAndUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signInAndUp(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
info
See all the functions that can be overrided here
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
(window as any).supertokensUIInit("supertokensui", {
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
(window as any).supertokensUIEmailPassword.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign up button.
signUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signUp(input);
},
// ...
// TODO: override more functions
}
}
}
}),
(window as any).supertokensUIThirdParty.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
// we will only be overriding what happens when a user
// clicks the sign in or sign up button.
signInAndUp: async function (input) {
// TODO: some custom logic
// or call the default behaviour as show below
return originalImplementation.signInAndUp(input);
},
// ...
// TODO: override more functions
}
}
}
})
]
});
originalImplementation
is an object that contains 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
signInAndUp
function of the ThirdParty recipe andsignUp
of the EmailPassword recipe. This means that when the user clicks the sign up button in the UI, your function will be called with the relevantinput
object.