JavaScript <CreateOrganization />
This JavaScript reference describes the properties and methods related to Clerk's <CreateOrganization />
component. If you are looking for the React component, see the <CreateOrganization />
documentation.
The <CreateOrganization />
component is used to render an organization creation UI that allows users to create brand new organizations within your application.
The following methods available on an instance of the Clerk
class are used to render and control the <CreateOrganization />
component:
mountCreateOrganization()
Render the <CreateOrganization />
component to an HTML <div>
element.
function mountCreateOrganization(node: HTMLDivElement, props?: CreateOrganizationProps): void;
mountCreateOrganization()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The <div> element used to render in the <CreateOrganization /> component |
props? | CreateOrganizationProps | The properties to pass to the <CreateOrganization /> component |
mountCreateOrganization()
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="create-organization"></div> `; const createOrgDiv = document.getElementById("create-organization"); clerk.mountOrganizationSwitcher(createOrgDiv);
index.html<!-- Add a <div id="create-organization"> element to your HTML --> <div id="create-organization"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const createOrgDiv = document.getElementById("create-organization"); Clerk.mountOrganizationSwitcher(createOrgDiv); }); </script>
unmountCreateOrganization()
Unmount and run cleanup on an existing <CreateOrganization />
component instance.
function unmountCreateOrganization(node: HTMLDivElement): void;
unmountCreateOrganization()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The container <div> element with a rendered <CreateOrganization /> component instance |
unmountCreateOrganization()
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="create-organization"></div> ` const createOrgDiv = document.getElementById('create-organization'); clerk.mountCreateOrganization(createOrgDiv); // ... clerk.unmountCreateOrganization(createOrgDiv);
index.html<!-- Add a <div id="create-organization"> element to your HTML --> <div id="create-organization"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const createOrgDiv = document.getElementById('create-organization'); Clerk.mountCreateOrganization(createOrgDiv); // ... Clerk.unmountCreateOrganization(createOrgDiv); }); </script>
openCreateOrganization()
Opens the <CreateOrganization />
component as an overlay at the root of your HTML body
element.
function openCreateOrganization(props?: CreateOrganizationProps): void;
openCreateOrganization()
params
Name | Type | Description |
---|---|---|
props? | CreateOrganizationProps | The properties to pass to the <CreateOrganization /> component |
openCreateOrganization()
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="create-organization"></div> ` const createOrgDiv = document.getElementById('create-organization'); clerk.openCreateOrganization(createOrgDiv);
index.html<!-- Add a <div id="create-organization"> element to your HTML --> <div id="create-organization"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const createOrgDiv = document.getElementById('create-organization'); Clerk.openCreateOrganization(createOrgDiv); }); </script>
closeCreateOrganization()
Closes the organization profile overlay.
function closeCreateOrganization(): void;
closeCreateOrganization()
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-switcher"></div> ` const orgSwitcherDiv = document.getElementById('organization-switcher'); clerk.openCreateOrganization(orgSwitcherDiv); // ... clerk.closeCreateOrganization(orgSwitcherDiv);
index.html<!-- Add a <div id="organization-switcher"> element to your HTML --> <div id="organization-switcher"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const orgSwitcherDiv = document.getElementById('organization-switcher'); Clerk.openCreateOrganization(orgSwitcherDiv); // ... Clerk.closeCreateOrganization(orgSwitcherDiv); }); </script>
CreateOrganizationProps
All props below are optional.
Name | Type | Description |
---|---|---|
afterCreateOrganizationUrl | string | Full URL or path to navigate after creating a new 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. -e.g. /create-org. This prop is ignored in hash and virtual based routing. |
appearance | Appearance | undefined | Optional object to style your components. Will only affect Clerk Components and not Account Portal pages. |