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
- Angular
- Vue
- Plain JavaScript
- React Native
Note
You can use the
You can refer to this example app as a reference for using the
supertokens-web-js
SDK which exposes several helper functions that query the APIs exposed by the SuperTokens backend SDK.You can refer to this example app as a reference for using the
supertokens-web-js
SDK.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
What type of UI are you using?
Prebuilt UICustom UI
What type of UI are you using?
Prebuilt UICustom UI
import ThirdParty from "supertokens-auth-react/recipe/thirdparty";
ThirdParty.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 === "GET_AUTHORISATION_URL") {
} else if (action === "THIRD_PARTY_SIGN_IN_UP") {
// Note: this could either be sign in or sign up.
// we don't know that at the time of the API call
// since all we have is the authorisation code from
// the social provider
} 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.