Wocha Docs

OrgSwitcher

Organisation switcher with multi-org support and profile modal/navigation.

The <OrgSwitcher> component lets signed-in users switch between organisations. It shows a dropdown of memberships and supports opening the organisation profile in modal or navigation mode.

Installation

pnpm add @wocha/ui @wocha/react
Or scaffold with the CLI
npx @wocha/cli init --framework nextjs
import { OrgSwitcher } from "@wocha/ui";
import "@wocha/ui/styles.css";

Basic usage

<OrgSwitcher
  getOrgLabel={(id) => orgNames[id] ?? id}
  createOrganisationUrl="/organisations/new"
  showSingle
/>

Props

PropTypeDefaultDescription
getOrgLabel(orgId: string) => stringResolve organisation IDs to display labels
createOrganisationUrlstringURL for creating a new organisation
onCreateOrganisation() => voidCalled when the user selects "Create organisation"
organisationProfileMode"modal" | "navigation""modal"How the organisation profile opens
organisationProfileUrlstringDestination when organisationProfileMode is "navigation"
appearanceWochaAppearanceVisual customisation
classNamestringAdditional class name
showSinglebooleanfalseShow switcher even when user has only one organisation
fallbackReactNodeShown while auth context is loading
// Opens OrganizationProfile in a modal overlay
<OrgSwitcher organisationProfileMode="modal" />
 
// Navigates to a dedicated settings page
<OrgSwitcher
  organisationProfileMode="navigation"
  organisationProfileUrl="/settings/organisation"
/>

Theming

import { corporate } from "@wocha/ui/themes";
 
<WochaThemeProvider appearance={{ theme: corporate, orgSwitcher: { radius: "sm" } }}>
  <OrgSwitcher showSingle />
</WochaThemeProvider>

Framework notes

FrameworkNotes
React SPAPlace in sidebar or header; requires multi-org user (orgIds on session)
Next.jsClient component; pair with OrganisationProfile page for navigation mode

On this page