Technical & DevelopmentAdvanced
organization-best-practices
Configure multi-tenant organizations, manage members and invitations, define custom roles and permissions, set up teams, and implement RBAC using Better Auth's organization plugin.
Developer Setup
Setup & Installation
bash
npx skills add https://github.com/better-auth/skills --skill organization-best-practicesnpx skills add https://github.com/better-auth/skills --skill organization-best-practicesOr paste this URL into your assistant to install:
Overview
What This Skill Does
Implements multi-tenant teams and organizations, role-based access control (RBAC), user invitations, and active organization scoping for subsequent API requests.
Application
When to use this Skill
- Building a multi-tenant B2B SaaS application where users belong to teams or workspaces.
- Enforcing role-based access control (RBAC) with pre-defined roles like Owner, Admin, and Member.
- Creating custom organization limits and membership counts per user tier (e.g., free vs premium).
- Implementing a secure invitation system to add members to an organization via email.
- Scoping subsequent API calls to a specific organization by setting the active organization in the user session.
Documentation
Show Skills.md file
Better Auth Organization Setup
Setup
- Add
organization()plugin to server config - Add
organizationClient()plugin to client config - Run
npx @better-auth/cli migrate - Verify: check that organization, member, invitation tables exist in your database
import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
export const auth = betterAuth({
plugins: [
organization({
allowUserToCreateOrganization: true,
organizationLimit: 5, // Max orgs per user
membershipLimit: 100, // Max members per org
}),
],
});
Client-Side Setup
Lines 1 - 25 of 134
Recommendations