Skip to main content

How to use

Use the override config#

import SuperTokens from "supertokens-node";import Session from "supertokens-node/recipe/session";
SuperTokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    supertokens: {        connectionURI: "...",    },    recipeList: [        Session.init({            override: {                functions: (originalImplementation) => {                    return {                        ...originalImplementation,
                        // here we are only overriding the function that's responsible                        // for creating a new session                        createNewSession: async function (input) {                            // TODO: some custom logic
                            // or call the default behaviour as show below                            return await originalImplementation.createNewSession(input);                        },                        // ...                        // TODO: override more functions                    }                }            }        })    ]});
  • originalImplementation is the object that contains functions that have the original implementaion for this recipe. It can be used in your functions as a way to use the SuperTokens' default behaviour.
  • In the above code snippet, we override the createNewSession function of this recipe. This can be used to (for example) modifying the session payload when a new session is created.
Which frontend SDK do you use?
supertokens-web-js / mobile