BuildBaseBuildBase

Overview

Control who can see and do what with role-based access control.

Every workspace member has a role. Use WhenPermission to show or hide UI, and usePermissions() when you need to check permissions in code.

import { Permission, WhenPermission } from '@buildbase/sdk/react';

function Sidebar() {
  return (
    <nav>
      <WhenPermission permission={Permission.WORKSPACE_MEMBERS_INVITE}>
        <a href="/team">Team</a>
      </WhenPermission>
      <WhenPermission permission={Permission.WORKSPACE_BILLING_MANAGE}>
        <a href="/billing">Billing</a>
      </WhenPermission>
    </nav>
  );
}

Default roles

Three roles ship with default permission sets:

RoleDefault permissions
ownerFull access — always has all permissions
adminAll workspace permissions except workspace deletion (owner-only)
memberView settings, members, features, billing, and usage
viewerView settings and members

Warning

The editor role is assignable (e.g. addUser(workspaceId, email, 'editor')) but has no entry in the default permission maps — an editor resolves to zero permissions until you configure custom permissions for the role, via defaultPermissions on SaaSOSProvider or the workspace permission matrix.

Custom roles can be defined in the BuildBase dashboard.

Components

ComponentWhat it checks
WhenPermissionDoes the user have a specific permission?
WhenRolesDoes the user have one of these org-level roles?
WhenWorkspaceRolesDoes the user have one of these workspace roles?
import { WhenWorkspaceRoles } from '@buildbase/sdk/react';

<WhenWorkspaceRoles roles={['owner', 'admin']}>
  <button onClick={() => openWorkspaceSettings()}>Settings</button>
</WhenWorkspaceRoles>;

usePermissions()

For imperative permission checks:

import { Permission, usePermissions } from '@buildbase/sdk/react';

function BillingPage() {
  const { can, isOwner, role } = usePermissions();

  if (!can(Permission.WORKSPACE_BILLING_MANAGE)) {
    return <p>No access to billing.</p>;
  }

  return <BillingSettings />;
}
ReturnTypeDescription
can(permission)functionCheck if user has a permission
permissionsSetFull set of resolved permissions
isOwnerbooleanWhether user owns the workspace
rolestringUser's role in the workspace

Custom permissions

Add app-specific permissions via SaaSOSProvider:

<SaaSOSProvider
  defaultPermissions={{
    admin: ['app:analytics:view', 'app:reports:export'],
    editor: ['app:analytics:view'],
  }}
>

Then check them: can('app:reports:export').

Next Steps