2.8 KiB
2.8 KiB
title, description, url
| title | description | url |
|---|---|---|
| Organizations/teams | Learn how to use organizations/teams/multi-tenancy in TurboStarter extension. | /docs/extension/organizations |
Organizations/teams
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.
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}</>;
}
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:
Looking for the underlying auth setup? Start with [Auth → Overview](/docs/extension/auth/overview) and [Auth → Session](/docs/extension/auth/session).