• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License
  • Global Configuration
    • Environment Variables
    • Feature Flags
  • Server Actions
    • Sending CSRF Token to Actions
    • Server Actions Error Handling
  • The Makerkit SDK
    • User SDK
    • Organization SDK
    • Organization Subscription SDK
    • Data Loader SDK
  • Architecture and Folder Structure
    • Structure your Application
    • Data Model
    • Commands
    • Code Style
    • Translations and Locales
    • Sending Emails
    • Validating API payload with Zod
    • Logging
    • Enable CORS
    • Encrypting Secrets
    • User Roles
This documentation is for a legacy version of Next.js and Supabase. For the latest version, please visit the Next.js and Supabase V2 documentation

Extend User Roles | Next.js Supabase SaaS Starter Kit

Learn how to extend the User Roles in the Next.js Supabase SaaS Starter Kit

The MakerKit Starter has three default roles:

tsx
enum MembershipRole {
Member = 0,
Admin = 1,
Owner = 2,
}
export default MembershipRole;

We use an enum, but you can convert this to an object if you need more granular permissions.

The permissions are hierarchical, which means that if we had a role with a lower level (Readonly), we would add it before Member:

tsx
export enum MembershipRole {
Readonly = 0,
Member = 1,
Admin = 2,
Owner = 3,
}

When writing permissions between users, we can check if the user performing the action has a greater role than the target user.

You can extend the role above easily by adding your own, for example:

tsx
export enum MembershipRole {
Readonly = 0,
AccountManager = 1,
Owner = 2,
}

Afterward, remember to add the name and descriptions of these roles in the translations file common.json:

json
"roles": {
"owner": {
"label": "Owner",
"description": "Can change any setting, invite new members and manage billing"
},
"accountmanager": {
"label": "Account Manager",
"description": "Can change some settings, invite members, perform disruptive actions"
},
"readonly": {
"label": "Readonly",
"description": "Can only read information"
}
}

Learn more about using user roles in your permissions system.

The role is stored in the database as a column in the memberships tabel.