Skip to main content

Initialisation

You can use this as a standalone recipe, or alongside any of the other recipes provided by us. To get started, initialise the recipe in the backend SDK's init function call:

import SuperTokens from "supertokens-node";
import UserRoles from "supertokens-node/recipe/userroles";

SuperTokens.init({
supertokens: {
connectionURI: "..."
},
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
UserRoles.init(),
]
});

By default, the user roles recipe will add the roles and permission information into a user's session (if they have assigned roles & permissions). If you do not want roles or permissions information in the session, or want to manually add it yourself, you can provide the following input configs to the UserRoles.init function:

import UserRoles from "supertokens-node/recipe/userroles";

UserRoles.init({
skipAddingRolesToAccessToken: true,
skipAddingPermissionsToAccessToken: true,
})
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI