Organization
better-auth-ui/organizationFreeComponent
Organization plugin: multi-tenant organization management with members, invitations, and roles. Registers direct invitation acceptance, an organizations settings tab, a full `<Organization />` shell, and an `<OrganizationSwitcher />` dropdown.
Live preview
live · rendered by the registry
Rendered by better-auth-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://better-auth-ui.com/r/organization.jsonSource
1"use client"23import type { OrganizationView } from "@better-auth-ui/core/plugins"4import {5 type OrganizationAuthClient,6 useActiveOrganization,7 useAuth,8 useAuthenticate,9 useAuthPlugin10} from "@better-auth-ui/react"11import { Settings as SettingsIcon, User2 as UserIcon } from "lucide-react"12import { useEffect, useMemo } from "react"1314import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"15import { organizationPlugin } from "@/lib/auth/organization-plugin"16import { cn } from "@/lib/utils"17import { OrganizationPeople } from "./organization-people"18import { OrganizationSettings } from "./organization-settings"1920export type OrganizationProps = {21 className?: string22 hideNav?: boolean23 path?: string24 /** @remarks `OrganizationView` */25 view?: OrganizationView26}2728/**29 * Organization management shell: tabs for profile / danger zone and for30 * people (members / invitations). Path segments come from31 * `useAuthPlugin(organizationPlugin).viewPaths.organization`.32 */33export function Organization({34 className,35 hideNav,36 path,37 view38}: OrganizationProps) {39 if (!view && !path) {40 throw new Error("[Better Auth UI] Either `view` or `path` must be provided")41 }4243 const { authClient, basePaths, localization, navigate } = useAuth()44 useAuthenticate(authClient)4546 const {47 localization: organizationLocalization,48 viewPaths: organizationViewPaths,49 slug,50 slugPrefix51 } = useAuthPlugin(organizationPlugin)5253 const { data: activeOrganization, isPending } = useActiveOrganization(54 authClient as OrganizationAuthClient55 )5657 useEffect(() => {58 if (!isPending && !activeOrganization) {59 navigate({60 to: `${basePaths.settings}/${organizationViewPaths.settings?.organizations}`,61 replace: true62 })63 }64 }, [65 basePaths.settings,66 isPending,67 navigate,68 organizationViewPaths.settings?.organizations,69 activeOrganization70 ])7172 const currentView = useMemo(() => {73 if (view) return view7475 const match = Object.entries(organizationViewPaths.organization).find(76 ([, segment]) => segment === path77 )7879 return match?.[0] as OrganizationView | undefined80 }, [view, path, organizationViewPaths.organization])8182 if (!currentView) {83 const validPaths = Object.values(organizationViewPaths.organization).join(84 ", "85 )86 throw new Error(87 `[Better Auth UI] Unknown organization path "${path}". Valid paths are: ${validPaths}`88 )89 }9091// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from better-auth-ui
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Account Settingsaccount-settings | better-auth-ui | Components | Free | 2 deps | |
| Active Sessionsactive-sessions | better-auth-ui | Components | Free | 5 deps · 2 files | |
| Additional Fieldadditional-field | better-auth-ui | Components | Free | 5 deps | |
| Adminadmin | better-auth-ui | Components | Free | 4 deps · 3 files | |
| Anonymousanonymous | better-auth-ui | Components | Free | 4 deps · 3 files | |
| API Keyapi-key | better-auth-ui | Components | Free | 4 deps · 10 files | |
| Authauth | better-auth-ui | Components | Free | 2 deps | |
| Auth Providerauth-provider | better-auth-ui | Components | Free | 4 deps · 2 files |
