Organization Management

Complete multi-tenancy support with organization switching, member management, and role-based access control.

For complete documentation and more examples, visit https://authcore-liard.vercel.app/

Overview

The Organization system provides everything you need for multi-tenancy:

  • Multiple Organizations per User - Users can create and join multiple organizations
  • Role-Based Access Control - Owner, Admin, and Member roles with different permissions
  • Organization Switching - Seamless switching between organizations
  • Member Management - Invite, remove, and manage organization members
  • Invitation System - Email-based invitations with expiration

Installation

bash

Components

OrganizationSwitcher

A dropdown component that allows users to switch between their organizations.

tsx

Live Demo

Props:

  • className?: string - Custom CSS classes
  • showCreateButton?: boolean - Show "Create Organization" button (default: true)

CreateOrganization

A modal form for creating new organizations.

tsx

Props:

  • onSuccess: (organization: Organization) => void - Callback on successful creation
  • onCancel: () => void - Callback when modal is closed
  • className?: string - Custom CSS classes

API Routes

Create Organization

Endpoint: POST /api/organizations

typescript

Context-Based State Management

Create a context to manage the current organization across your app:

typescript

Database Schema

The organization system uses the following Prisma models:

  • Organization - Main organization entity with name, slug, and description
  • OrganizationMember - Links users to organizations with roles (owner, admin, member)
  • OrganizationInvitation - Email-based invitations with tokens and expiration

Custom Domains

If you'd like organizations to map their own domains (e.g. acme.com), see the custom domain example which includes a Prisma schema snippet, verification flow, and middleware example to resolve requests by Host.

View custom domain example →

Tips

  • Scoping data: Always scope organization data by org ID on the server to prevent cross-tenant leaks.
  • Permissions: Implement role checks (owner/admin) in API routes and UI actions rather than relying on client props.
  • Create flow: Validate slugs and uniqueness server-side; return helpful error messages for slug conflicts.
  • Testing: Seed test tenants and users to test switching and permission boundaries in integration tests.