Organizations/teams
Learn how to use organizations/teams/multi-tenancy in TurboStarter extension.
TurboStarter extensions support organizations/teams out of the box by sharing the same authentication session as your web app. The active organization is stored in the session and available to your extension without re-implementing organizations logic.
Shared session and tenant context
The extension and web app use a single auth session powered by Better Auth. The session includes tenant context (for example, activeOrganizationId
). When users sign in, switch organizations, or sign out in the web app, the extension picks up these changes automatically.
Learn more: Auth → Session.
How it works
- No separate auth flow in the extension. We reuse the web session.
- Active organization comes from the session (e.g.,
session.activeOrganizationId
). - Protected API calls from the extension include the right cookies, so org‑scoped server logic works as expected.
Active organization
Use your existing auth client to read the active organization through the useActiveOrganization
hook.
import { authClient } from "~/lib/auth";
export function Popup() {
const organization = authClient.useActiveOrganization();
return <>{organization?.name}</>;
}
Switching organizations
If a user switches organizations in the web app, the extension reflects the change through the shared session on the next interaction. For long-lived views, re-read the session or invalidate related queries when appropriate.
Do more with organizations
Most organization features live in the web app and are exposed via APIs your extension can call. These guides explain the underlying concepts and server behavior your extension builds upon:
Overview
Concepts and architecture
Data model
Tables and relationships
Active organization
How organization context is resolved
RBAC
Roles and permissions
Invitations
Invite teammates and manage members
Looking for the underlying auth setup? Start with Auth → Overview and Auth → Session.
How is this guide?
Last updated on