Skip to main content
important

This is a contributors guide and NOT a user guide. Please visit these docs if you are using or evaluating SuperTokens.

About overrides + user context

  • 1) They are used by the user to change / enhance the default behaviour of our recipes

  • 2) As the name suggests, they are related to the concept of inheritance. So if we have the following scenario:

    a() {
    ...
    b();
    ...
    }

    b() {
    ...
    }

    And then the user overrides function b(), and then calls a()somewhere, then their call must call the new version ofb()`.

  • 3) User context: All functions should take a reference of an object in which the user can add anything into. This would allow the user to provide their customisations only in certain situations depending on the context of where the recipe function is being called from.

    For example, a user might want to modify createNewSession function only if it being called from the signUp function and not the signIn function. To do this, they can set some custom context in the signUp function which gets passed to createNewSession function and in there, they can identify the custom context and run their logic.

  • 4) Calling recipe functions in our code: We have to be very careful when we call recipe functions in our code, especially if we are calling them in another overrideable function (see https://github.com/supertokens/supertokens-website/issues/99).

    We should avoid scenarios where we are calling a recipe function in another function which doesn't have the user context as an input to it, and that function in turn is possibly called within another overrideable function (since it can lead to unavoidable infinite recursions).

Which UI do you use?
Custom UI
Pre built UI