Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

<OrganizationList /> component

Organization List Example

The <OrganizationList /> component is used to display organization related memberships, invitations, and suggestions for the user.

Properties

All props are optional.

NameTypeDescription
hidePersonalbooleanBy default, users can switch between organization and their personal account. This option controls whether <OrganizationList /> will include the user's personal account in the organization list. Setting this to false will hide the personal account entry, and users will only be able to switch between organizations.
Defaults to false.
skipInvitationScreenboolean | undefinedHides the screen for sending invitations after an organization is created. When left undefined Clerk will automatically hide the screen if the number of max allowed members is equal to 1.
Defaults to false.
appearanceAppearance | undefinedOptional object to style your components. Will only affect Clerk Components and not Account Portal pages.
afterCreateOrganizationUrl((org: Organization) => string) | stringFull URL or path to navigate to after creating a new organization.
afterSelectOrganizationUrl((org: Organization) => string) | stringFull URL or path to navigate to after selecting an organization.
Defaults to undefined.
afterSelectPersonalUrl((org: Organization) => string) | stringFull URL or path to navigate to after selecting the personal account.
Defaults to undefined.

Usage with frameworks

/app/discover/page.tsx
import { OrganizationList } from "@clerk/nextjs"; export default function OrganizationListPage() { return ( <OrganizationList afterCreateOrganizationUrl='/organization/:slug' afterSelectPersonalUrl='/user/:id' afterSelectOrganizationUrl='/organization/:slug' /> ); }
/pages/discover.tsx
import { OrganizationList } from "@clerk/nextjs"; export default function OrganizationListPage() { return ( <OrganizationList afterCreateOrganizationUrl={org => `/organization/${org.slug}`} afterSelectPersonalUrl={user => `/user/${user.id}`} afterSelectOrganizationUrl={org => `/organization/${org.slug}`} /> ); }

Usage with JavaScript

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

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

mountOrganizationList()

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

function mountOrganizationList(node: HTMLDivElement, props?: OrganizationListProps): void;

mountOrganizationList() params

NameTypeDescription
nodeHTMLDivElement(opens in a new tab)The <div> element used to render in the <OrganizationList /> component
props?OrganizationListPropsThe properties to pass to the <OrganizationList /> component

mountOrganizationList() usage

main.js
import Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); document.getElementById("app").innerHTML = ` <div id="organization-list"></div> `; const orgListDiv = document.getElementById("organization-list"); clerk.mountOrganizationList(orgListDiv);
index.html
<!-- Add a <div id="organization-list"> element to your HTML --> <div id="organization-list"></div> <!-- Initialize Clerk with your Clerk Publishable key and Frontend API URL --> <script async crossorigin="anonymous" data-clerk-publishable-key="{{pub_key}}" src="https://{{fapi_url}}/npm/@clerk/clerk-js@latest/dist/clerk.browser.js" type="text/javascript" ></script> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgListDiv = document.getElementById('organization-list'); Clerk.mountOrganizationList(orgListDiv); }); </script>

unmountOrganizationList()

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

function unmountOrganizationList(node: HTMLDivElement): void;

unmountOrganizationList() params

NameTypeDescription
nodeHTMLDivElement(opens in a new tab)The container <div> element with a rendered <OrganizationList /> component instance

unmountOrganizationList() usage

main.js
import Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); document.getElementById('app').innerHTML = ` <div id="organization-list"></div> ` const orgListDiv = document.getElementById('organization-list'); clerk.mountOrganizationList(orgListDiv); // ... clerk.unmountOrganizationList(orgListDiv);
index.html
<!-- Add a <div id="organization-list"> element to your HTML --> <div id="organization-list"></div> <!-- Initialize Clerk with your Clerk Publishable key and Frontend API URL --> <script async crossorigin="anonymous" data-clerk-publishable-key="{{pub_key}}" src="https://{{fapi_url}}/npm/@clerk/clerk-js@latest/dist/clerk.browser.js" type="text/javascript" ></script> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgListDiv = document.getElementById('organization-list'); Clerk.mountOrganizationList(orgListDiv); // ... Clerk.unmountOrganizationList(orgListDiv); }); </script>

Force organizations

If you would like to prohibit people from using their personal accounts and force them to be part of an organization, the hidePersonal property forces your user to join or create an organization in order to continue. For more information on how to hide Personal Accounts and force organizations, see the dedicated guide.

organization-portal.tsx
export default function OrganizationListPage() { return ( <OrganizationList hidePersonal={true} {...} /> ); };

Customization

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

Last updated on March 26, 2024

What did you think of this content?

Clerk © 2024