About functions override
Overriding of the functions will allow you to change the behaviour of the functions that are used by the APIs that are exposed via our SDK. Example functions are:
- Sign in / up
- Saving a session
- Creating / Revoking a session
- Signing out
- And more...
Some common use cases:
- If a recipe wants to check if a session exists, it will call the session recipe's
doesSessionExist
function. - You already have your own sign-up/sign-in flow and want to migrate to Supertokens. Overriding the functions will allow you to let the old users sign-in via your custom logic and let new users sign-up/sign-in via Supertokens.
- You want to use your own custom userId format. Overriding various functions will allow you to map your own userIds to the ones generated by SuperTokens.
- In the default implementation of the session recipe, we check this via a token stored in the localstorage (this is not an access token).
- However, if you implement your own session management, you can override this function on the frontend to work with your solution, and all the other recipes that use this function, will continue to work as expected.