BuildBaseBuildBase

Checking Permissions

Check permissions in code for conditional logic and gating.

Use usePermissions() when you need to check permissions in code — for conditional logic, disabling buttons, or gating API calls.

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

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

  if (!can(Permission.WORKSPACE_BILLING_MANAGE)) {
    return <p>You don't have access to billing.</p>;
  }

  return <BillingSettings showDangerZone={isOwner} />;
}

Permission constants

Use Permission.* constants for type-safe permission checks. They autocomplete in your editor.

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

// Single permission
can(Permission.WORKSPACE_BILLING_MANAGE);

// Multiple — returns true only if user has ALL
can([Permission.WORKSPACE_SETTINGS_VIEW, Permission.WORKSPACE_SETTINGS_EDIT]);

Available constants: WORKSPACE_SETTINGS_VIEW, WORKSPACE_SETTINGS_EDIT, WORKSPACE_DELETE, WORKSPACE_MEMBERS_VIEW, WORKSPACE_MEMBERS_INVITE, WORKSPACE_MEMBERS_REMOVE, WORKSPACE_MEMBERS_ROLE_CHANGE, WORKSPACE_FEATURES_VIEW, WORKSPACE_FEATURES_EDIT, WORKSPACE_BILLING_VIEW, WORKSPACE_BILLING_MANAGE, WORKSPACE_USAGE_VIEW.

Tip

Use Permission.* constants instead of raw strings. See the SDK README for the full list.

Custom app permissions

Add your own via defaultPermissions on SaaSOSProvider, then check them the same way:

const { can } = usePermissions();
if (can('app:reports:export')) {
  // show export button
}

Next Steps