JavaScript <OrganizationProfile />
This JavaScript reference describes the properties and methods related to Clerk's <OrganizationProfile />
component. If you are looking for the React component, see the <OrganizationProfile />
documentation.
The <OrganizationProfile />
component is used to render a beautiful, full-featured organization management UI that allows users to manage their organization profile and security settings.
The following methods available on an instance of the Clerk
class are used to render and control the <OrganizationProfile />
component:
mountOrganizationProfile()
unmountOrganizationProfile()
openOrganizationProfile()
closeOrganizationProfile()
mountOrganizationProfile()
Render the <OrganizationProfile />
component to an HTML <div>
element.
function mountOrganizationProfile(node: HTMLDivElement, props?: OrganizationProfileProps): void;
mountOrganizationProfile()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The <div> element used to render in the <OrganizationProfile /> component |
props? | OrganizationProfileProps | The properties to pass to the <OrganizationProfile /> component |
mountOrganizationProfile()
usage
main.jsimport 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-profile"></div> `; const orgProfileDiv = document.getElementById("organization-profile"); clerk.mountOrganizationProfile(orgProfileDiv);
index.html<!-- Add a <div id="organization-profile"> element to your HTML --> <div id="organization-profile"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgProfileDiv = document.getElementById('organization-profile'); Clerk.mountOrganizationProfile(orgProfileDiv); }); </script>
unmountOrganizationProfile()
Unmount and run cleanup on an existing <OrganizationProfile />
component instance.
function unmountOrganizationProfile(node: HTMLDivElement): void;
unmountOrganizationProfile()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The container <div> element with a rendered <OrganizationProfile /> component instance. |
unmountOrganizationProfile()
usage
main.jsimport 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-profile"></div> ` const orgProfileDiv = document.getElementById('organization-profile'); clerk.mountOrganizationProfile(orgProfileDiv); // ... clerk.unmountOrganizationProfile(orgProfileDiv);
index.html<!-- Add a <div id="organization-profile"> element to your HTML --> <div id="organization-profile"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgProfileDiv = document.getElementById('organization-profile'); Clerk.mountOrganizationProfile(orgProfileDiv); // ... Clerk.unmountOrganizationProfile(orgProfileDiv); }); </script>
openOrganizationProfile()
Opens the <OrganizationProfile />
component as an overlay at the root of your HTML body
element.
function openOrganizationProfile(props?: OrganizationProfileProps): void;
openOrganizationProfile()
params
Name | Type | Description |
---|---|---|
props? | OrganizationProfileProps | The properties to pass to the <OrganizationProfile /> component |
openOrganizationProfile()
usage
main.jsimport 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-profile"></div> ` const orgProfileDiv = document.getElementById('organization-profile'); clerk.openOrganizationProfile(orgProfileDiv);
index.html<!-- Add a <div id="organization-profile"> element to your HTML --> <div id="organization-profile"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgProfileDiv = document.getElementById('organization-profile'); Clerk.openOrganizationProfile(orgProfileDiv); }); </script>
closeOrganizationProfile()
Closes the organization profile overlay.
function closeOrganizationProfile(): void;
closeOrganizationProfile()
usage
main.jsimport 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-profile"></div> ` const orgProfileDiv = document.getElementById('organization-profile'); clerk.closeOrganizationProfile(orgProfileDiv);
index.html<!-- Add a <div id="organization-profile"> element to your HTML --> <div id="organization-profile"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgProfileDiv = document.getElementById('organization-profile'); Clerk.closeOrganizationProfile(orgProfileDiv); }); </script>
OrganizationProfileProps
All props below are optional.
Name | Type | Description |
---|---|---|
afterLeaveOrganizationUrl | string | Full URL or path to navigate after leaving an organization. |
routing | 'hash' | 'path' | 'virtual' | The routing strategy for your pages. |
path | string | The path where the component is mounted when path-based routing is used. For example: /organization-profile .This prop is ignored in hash-based routing. |
appearance | Appearance | Optional object to style your components. Will only affect Clerk Components and not Account Portal pages. |
customPages | CustomPage[] | An array of custom pages to add to the organization profile. |
How to customize the <OrganizationProfile />
component
To learn about how to customize Clerk components, see the customization documentation.
In addition, you also can add custom pages and links to the navigation sidebar of the <OrganizationProfile />
component. See the example below:
main.jsimport Clerk from '@clerk/clerk-js'; const clerk = new Clerk('{{pub_key}}'); await clerk.load(); clerk.openOrganizationProfile({ customPages: [ { url: "custom-page", label: "Custom Page", mountIcon: (el) => { el.innerHTML = "π"; }, unmountIcon: (el) => { el.innerHTML = ""; }, mount: (el) => { el.innerHTML = ` <h1><b>Custom Page</b></h1> <p>This is the content of the custom page.</p> `; }, unmount: (el) => { el.innerHTML = ""; }, }, { url: "/other-page", label: "Other Page", mountIcon: (el) => { el.innerHTML = "π"; }, unmountIcon: (el) => { el.innerHTML = ""; }, } ] });
index.html<script> window.addEventListener('load', async function () { await Clerk.load(); Clerk.openOrganizationProfile({ customPages: [ { url: "custom-page", label: "Custom Page", mountIcon: (el) => { el.innerHTML = "π"; }, unmountIcon: (el) => { el.innerHTML = ""; }, mount: (el) => { el.innerHTML = ` <h1><b>Custom Page</b></h1> <p>This is the content of the custom page.</p> `; }, unmount: (el) => { el.innerHTML = ""; }, }, { url: "/other-page", label: "Other Page", mountIcon: (el) => { el.innerHTML = "π"; }, unmountIcon: (el) => { el.innerHTML = ""; }, } ] }); }); </script>