How to use
#
Use the override configinfo
See all the functions that can be overrided here
- ReactJS
- Plain JavaScript
- React Native
Note
To use SuperTokens with plain javascript you need to use the
To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
You can refer to this blog post to know how this is done, the example uses social login but the same setup applies to other recipes as well.
supertokens-website
SDK. The SDK provides session management features.To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
You can refer to this blog post to know how this is done, the example uses social login but the same setup applies to other recipes as well.
Note
To use SuperTokens with React Native you need to use the
To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
supertokens-react-native
SDK. The SDK provides session management features.To add login functionality, you need to build your own UI and call the APIs exposed by the backend SDKs. You can find the API spec here
import SuperTokens from "supertokens-auth-react";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 in button. signIn: async function (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 function (input) { // TODO: some custom logic
// or call the default behaviour as show below return originalImplementationEmailVerification.isEmailVerified(input); }, // ... // TODO: override emailverification functions here } } } } }) ]});
originalImplementation
andoriginalImplementationEmailVerification
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 relevantinput
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.