organization-best-practices
Installation
Summary
Multi-tenant organization setup with member management, role-based access control, and team support via Better Auth.
- Configure organizations with customizable creation rules, membership limits, and ownership constraints; creators automatically receive the owner role
- Manage members and invitations with email delivery, expiration windows, and shareable invitation URLs; support multiple roles per member
- Define custom roles and permissions with dynamic access control; check permissions server-side via
hasPermissionendpoint or client-side viacheckRolePermission - Create and manage teams within organizations with configurable member and team limits; set active teams to scope API calls
- Use lifecycle hooks (beforeCreate, afterCreate, beforeDelete) and schema customization to extend default behavior and integrate with external systems
SKILL.md
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";