Skip to main content

Creating a new role

When using SuperTokens, roles and permissions are simple strings that can be assigned to users and verified on your backend and frontend.

When creating new roles you can choose to add 0 or multiple permissions to the role.

important

Roles must be ceated before they can be assigned to users

tip

Roles can also be created from the user management dashboard. To know more about how to manage your user roles and permissions from user management dashboard see this page.

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

async function createRole() {
const response = await UserRoles.createNewRoleOrAddPermissions("user", ["read"]);

if (response.createdNewRole === false) {
// The role already exists
}
}
Multi Tenancy

In a multi tenant setup, roles and permissions are shared across all tenants. This means that you can create a role and add permissions to it once, and reuse that role across any tenant in your app.