šŸ“ Sign Up | šŸ” Log In

← Root | ↑ Up

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ šŸ“„ shadcn/directory/clerk/clerk-docs/reference/components/organization/organization-switcher │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

╔══════════════════════════════════════════════════════════════════════════════════════════════╗
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘

title: '<OrganizationSwitcher /> component' description: Clerk's <OrganizationSwitcher /> component is used to enable the ability to switch between available organizations the user may be part of in your application. sdk: astro, chrome-extension, expo, nextjs, nuxt, react, react-router, remix, tanstack-react-start, vue, js-frontend

The <OrganizationSwitcher /> component allows a user to switch between their account types - their personal account and their joined organizations.{{ style: { maxWidth: '436px' } }}

The <OrganizationSwitcher /> component allows a user to switch between their joined organizations. If personal accounts are enabled, users can also switch to their personal account. This component is useful for applications that have a multi-tenant architecture, where users can be part of multiple organizations. It handles all organization-related flows, including full organization management for admins. Learn more about organizations.

<If sdk={["astro", "chrome-extension", "expo", "nextjs", "nuxt", "react", "react-router", "remix", "tanstack-react-start", "vue"]}

Example

<If sdk="nextjs"> ```jsx {{ filename: 'app/organization-switcher/[[...organization-switcher]]/page.tsx' }} import { OrganizationSwitcher } from '@clerk/nextjs'
export default function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="react"> ```jsx {{ filename: 'src/App.tsx' }} import { OrganizationSwitcher } from '@clerk/clerk-react'
function App() {
  return <OrganizationSwitcher />
}

export default App
```
</If> <If sdk="astro"> ```astro {{ filename: '/pages/organization-switcher.astro' }} --- import { OrganizationSwitcher } from '@clerk/astro/components' ---
<OrganizationSwitcher />
```
</If> <If sdk="expo"> <Include src="_partials/expo/web-only-callout" />
```jsx {{ filename: '/app/organization-switcher.web.tsx' }}
import { OrganizationSwitcher } from '@clerk/clerk-expo/web'

export default function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="chrome-extension"> ```jsx {{ filename: 'src/routes/organization-switcher.tsx' }} import { OrganizationSwitcher } from '@clerk/chrome-extension'
export default function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="remix"> ```tsx {{ filename: 'app/routes/organization-switcher.tsx' }} import { OrganizationSwitcher } from '@clerk/remix'
export default function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="react-router"> ```tsx {{ filename: 'app/routes/organization-switcher.tsx' }} import { OrganizationSwitcher } from '@clerk/react-router'
export default function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="tanstack-react-start"> ```tsx {{ filename: 'app/routes/organization-switcher.tsx' }} import { OrganizationSwitcher } from '@clerk/tanstack-react-start' import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/organization-switcher')({
  component: OrganizationSwitcherPage,
})

function OrganizationSwitcherPage() {
  return <OrganizationSwitcher />
}
```
</If> <If sdk="vue"> ```vue {{ filename: 'organization-switcher.vue' }} <script setup lang="ts"> import { OrganizationSwitcher } from '@clerk/vue' </script>
<template>
  <OrganizationSwitcher />
</template>
```
</If> <If sdk="nuxt"> ```vue {{ filename: 'pages/organization-switcher.vue' }} <script setup lang="ts"> // Components are automatically imported </script>
<template>
  <OrganizationSwitcher />
</template>
```
</If> </If> <If sdk="js-frontend"> ## Usage with JavaScript

The following methods available on an instance of the Clerk class are used to render and control the <OrganizationSwitcher /> component:

The following examples assume that you have followed the quickstart in order to add Clerk to your JavaScript application.

mountOrganizationSwitcher()

Render the <OrganizationSwitcher /> component to an HTML <div> element.

function mountOrganizationSwitcher(node: HTMLDivElement, props?: OrganizationSwitcherProps): void

<code>mountOrganization<wbr />Switcher()</code> params

<Properties> - `node` - [`HTMLDivElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement)
The `<div>` element used to render in the `<OrganizationSwitcher />` component

---

- `props?`
- [`OrganizationSwitcherProps`](#properties)

The properties to pass to the `<OrganizationSwitcher />` component
</Properties>

<code>mountOrganization<wbr />Switcher()</code> usage

import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="organization-switcher"></div>
`

const orgSwitcherDiv = document.getElementById('organization-switcher')

clerk.mountOrganizationSwitcher(orgSwitcherDiv)

<code>unmountOrganization<wbr />Switcher()</code>

Unmount and run cleanup on an existing <OrganizationSwitcher /> component instance.

function unmountOrganizationSwitcher(node: HTMLDivElement): void

<code>unmountOrganization<wbr />Switcher()</code> params

<Properties> - `node` - [`HTMLDivElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement)
The container `<div>` element with a rendered `<OrganizationSwitcher />` component instance
</Properties>

<code>unmountOrganization<wbr />Switcher()</code> usage

import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="organization-switcher"></div>
`

const orgSwitcherDiv = document.getElementById('organization-switcher')

clerk.mountOrganizationSwitcher(orgSwitcherDiv)

// ...

clerk.unmountOrganizationSwitcher(orgSwitcherDiv)
</If>

Properties

The <OrganizationSwitcher /> component accepts the following properties, all of which are optional:

<Properties> - `afterCreateOrganizationUrl` - `string`

The full URL or path to navigate to after creating a new organization.


  • afterLeaveOrganizationUrl
  • string

The full URL or path to navigate to after the user leaves the currently active organization.


  • afterSelectOrganizationUrl
  • string

The full URL or path to navigate to after a successful organization switch.


Optional object to style your components. Will only affect Clerk components and not Account Portal pages.


  • createOrganizationMode
  • 'modal' | 'navigation'

A boolean that controls whether clicking the "Create organization" button will cause the <CreateOrganization /> component to open as a modal, or if the browser will navigate to the createOrganizationUrl where <CreateOrganization /> is mounted as a page. Defaults to: 'modal'.


  • createOrganizationUrl
  • string

The full URL or path where the <CreateOrganization />]createorg-ref component is mounted.


  • defaultOpen
  • boolean

A boolean that controls the default state of the <OrganizationSwitcher /> component.


  • fallback?
  • ReactNode

An optional element to be rendered while the component is mounting.


  • hidePersonal
  • boolean

A boolean that controls whether <OrganizationSwitcher /> will include the user's personal account in the organization list. Setting this to true will hide the personal account option, and users will only be able to switch between organizations. Defaults to false.


  • hideSlug
  • boolean

A boolean that controls whether the optional slug field in the organization creation screen is hidden.


  • organizationProfileMode
  • 'modal' | 'navigation'

A boolean that controls whether clicking the Manage organization button will cause the <OrganizationProfile /> component to open as a modal, or if the browser will navigate to the organizationProfileUrl where <OrganizationProfile /> is mounted as a page. Defaults to: 'modal'.


  • organizationProfileProps
  • object

Specify options for the underlying <OrganizationProfile /> component. For example: {appearance: {...}}


  • organizationProfileUrl
  • string

The full URL or path where the <OrganizationProfile /> component is mounted. </Properties>

Customization

To learn about how to customize Clerk components, see the customization documentation.

ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

← Root | ↑ Up