Tenant memberships and permission helper
membershipsMemberships with roles, member_organization_ids() and has_organization_role() for RLS policies, and membership_claims() for the access token hook. Adopt an existing memberships table through blocks.memberships.
Tenancy & accountsmanagedadoptcustom
Install
The command also installs updated-at, the modules it needs.
npx better-supabase add membershipsConfigure
The blocks entries in your config, with the default mode.
import { defineConfig } from "better-supabase/config";
export default defineConfig({
blocks: {
// Required by memberships; add installs them too.
"updated-at": {},
// Modes: "managed", "adopt", "custom". The default is "managed".
memberships: { mode: "managed" },
},
});Migrations
The files
npx better-supabase add memberships writes into your declarative schema with the default layout.Client
This block has no React entry yet. Its TypeScript side is in better-supabase/blocks/memberships, which runs on the server.
Events
With the outbox installed, the module writes these in the same transaction as the change.
This module writes no outbox events.
Dependencies
Recipes
No UI recipe uses it yet. See all recipes.
More in Tenancy & accounts
- Invitationsinvitationsinvite_member(tenant, email, role) returns a single-use token whose hash is stored; accept_invitation(token) checks the signed-in user's confirmed email and, again, the inviter's authority. Roles follow the access model; a null tenant invites to a platform role, stored in platform_invitations.
- Reserved slugsreserved-slugsA slug format and length check and a list of reserved words (admin, api, www, ...), enforced by a trigger.
- Organizationsorganizationscreate_organization(attrs) with slug rules and an after-create hook, a deferred owner check, an assignment ceiling, and member functions (role change, remove, leave, transfer ownership) on the access contract.React hooks
- ProfilesprofilesA profile per user, created on sign-up from auth metadata with a unique username, an email mirror, column-level update grants and a guard on columns the service owns.
- SettingssettingsPer-user, per-organization and platform-wide settings as key-value jsonb rows. Users read and write their own; organization settings check settings.read and settings.update; platform settings check a platform permission per key. Keys with a JSON Schema in options.schemas get a pg_jsonschema check.React hooks
- TeamsteamsTenant teams and their members. Inbox assignment uses these rows instead of its own team tables.