useOrganizationList()
import { useOrganizationList } from '@auth/clerk'
- useOrganizationList()
Access the current user’s organizations and manage the active organization with a universal import path.
Usage
OrganizationSwitcher.tsx
import { useOrganizationList } from '@auth/clerk'
export const OrganizationSwitcher = () => {
const { isLoaded, setActive, organizationList } = useOrganizationList()
if (!isLoaded) return null
return (
<View>
{organizationList?.map(({ organization }) => (
<Button
key={organization.id}
title={organization.name || organization.id}
onPress={() => setActive?.({ organization: organization.id })}
/>
))}
</View>
)
}
API
Returned values (selection)
isLoaded: boolean
— Whether the organizations list is hydrated.organizationList?: { organization: OrganizationResource }[]
— List of orgs the user belongs to.setActive?: (params: { organization: string | null }) => Promise<void>
— Set the active organization (ornull
).
See official docs for full details: https://clerk.com/docs/nextjs/reference/hooks/use-organization-list