Pre API Hook
This function is called before any API call is being made to your backend from our frontend SDK. You can use this to change the request body / url / header or any other request property.
- 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 EmailPassword from "supertokens-auth-react/recipe/emailpassword";
EmailPassword.init({ preAPIHook: async (context) => { let url = context.url; // is the fetch config object that contains the header, body etc.. let requestInit = context.requestInit;
let action = context.action; if (action === "EMAIL_EXISTS") {
} else if (action === "IS_EMAIL_VERIFIED") {
} else if (action === "SEND_RESET_PASSWORD_EMAIL") {
} else if (action === "SEND_VERIFY_EMAIL") {
} else if (action === "EMAIL_PASSWORD_SIGN_IN") {
} else if (action === "EMAIL_PASSWORD_SIGN_UP") {
} else if (action === "SUBMIT_NEW_PASSWORD") {
} else if (action === "VERIFY_EMAIL") {
}
// events such as sign out are in the // session recipe pre API hook (See the info box below) return { requestInit, url }; }})
info
Also checkout the session recipe pre API hook for events such as sign out. These will need to go in the Session.init
config object.