Add custom pages and links to the <OrganizationProfile />
component
The <OrganizationProfile />
component supports the addition of custom pages and external links to the component's sidenav.
Before you start
To access the <OrganizationProfile />
component, the user must select the <OrganizationSwitcher />
component and then select the Manage Organization option. The <OrganizationProfile />
will open as a modal by default. You can also render the component as a dedicated page. This guide includes examples for both use cases. On the code examples, you can select one of the following two tabs to see the implementation for your preferred use case:
<OrganizationSwitcher />
tab: By default, the<OrganizationSwitcher />
setsorganizationProfileMode='modal'
. If you are using the default settings, then you should select this tab.Dedicated page
tab: If you do not want the<OrganizationProfile />
to open as a modal, then you should select this tab. For these examples, you need to setorganizationProfileMode='navigation'
andorganizationProfileUrl='/organization-profile'
on the<OrganizationSwitcher />
component.
Add a custom page
To add a custom page to the <OrganizationProfile />
component, use the <OrganizationSwitcher.OrganizationProfilePage />
component or the <OrganizationProfile.Page />
component, depending on your use case.
Props
<OrganizationSwitcher.OrganizationProfilePage />
and <OrganizationProfile.Page />
accept the following props, all of which are required:
- Name
label
- Type
string
- Description
The name that will be displayed in the navigation sidebar for the custom page.
- Name
labelIcon
- Type
React.ReactElement
- Description
An icon displayed next to the label in the navigation sidebar.
- Name
url
- Type
string
- Description
The path segment that will be used to navigate to the custom page. For example, if the
<OrganizationProfile />
component is rendered at/organization
, then the custom page will be accessed at/organization/{url}
when using path routing.
- Name
children
- Type
React.ReactElement
- Description
The content to be rendered inside the custom page.
The following example demonstrates two ways that you can render content in a custom page: as a component or as a direct child.
'use client'
import { OrganizationSwitcher } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const CustomPage = () => {
return (
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
)
}
const Header = () => (
<header>
<OrganizationSwitcher>
{/* You can pass the content as a component */}
<OrganizationSwitcher.OrganizationProfilePage
label="Custom Page"
url="custom"
labelIcon={<DotIcon />}
>
<CustomPage />
</OrganizationSwitcher.OrganizationProfilePage>
{/* You can also pass the content as direct children */}
<OrganizationSwitcher.OrganizationProfilePage
label="Terms"
labelIcon={<DotIcon />}
url="terms"
>
<div>
<h1>Custom Terms Page</h1>
<p>This is the content of the custom terms page.</p>
</div>
</OrganizationSwitcher.OrganizationProfilePage>
</OrganizationSwitcher>
</header>
)
export default Header
'use client'
import { OrganizationProfile } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const CustomPage = () => {
return (
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
)
}
const OrganizationProfilePage = () => (
<OrganizationProfile path="/organization-profile" routing="path">
{/* You can pass the content as a component */}
<OrganizationProfile.Page label="Custom Page" labelIcon={<DotIcon />} url="custom-page">
<CustomPage />
</OrganizationProfile.Page>
{/* You can also pass the content as direct children */}
<OrganizationProfile.Page label="Terms" labelIcon={<DotIcon />} url="terms">
<div>
<h1>Custom Terms Page</h1>
<p>This is the content of the custom terms page.</p>
</div>
</OrganizationProfile.Page>
</OrganizationProfile>
)
export default OrganizationProfilePage
To add custom pages to the <OrganizationProfile />
component using the JavaScript SDK, pass the customPages
property to the mountOrganizationProfile()
or openOrganizationProfile()
method, as shown in the following example:
import { Clerk } from '@clerk/clerk-js'
const pubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY
const clerk = new Clerk(pubKey)
await clerk.load()
document.getElementById('app').innerHTML = `
<div id="organization-profile"></div>
`
const orgProfileDiv = document.getElementById('organization-profile')
clerk.openOrganizationProfile(orgProfileDiv, {
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 setup lang="ts">
import { OrganizationSwitcher } from '@clerk/vue'
</script>
<template>
<header>
<OrganizationSwitcher>
<OrganizationSwitcher.OrganizationProfilePage label="Custom Page" url="custom">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
</OrganizationSwitcher.OrganizationProfilePage>
</OrganizationSwitcher>
</header>
</template>
<script setup lang="ts">
import { OrganizationProfile } from '@clerk/vue'
</script>
<template>
<OrganizationProfile>
<OrganizationProfile.Page label="Custom Page" url="custom">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
</OrganizationProfile.Page>
</OrganizationProfile>
</template>
Add a custom link
To add an external link to the <OrganizationProfile />
navigation sidebar, use the <OrganizationSwitcher.OrganizationProfileLink />
component or the <OrganizationProfile.Link />
component, depending on your use case.
Props
<OrganizationSwitcher.OrganizationProfileLink />
and <OrganizationProfile.Link />
accept the following props, all of which are required:
- Name
label
- Type
string
- Description
The name that will be displayed in the navigation sidebar for the link.
- Name
labelIcon
- Type
React.ReactElement
- Description
An icon displayed next to the label in the navigation sidebar.
- Name
url
- Type
string
- Description
The full URL or path that will be used to navigate to the external link. For path segments, if the
<OrganizationProfile />
component is rendered at/organization
, then the external link will be accessed at/organization/{url}
when using path routing.
Example
The following example adds a custom link to the <OrganizationProfile />
sidenav that navigates to the homepage.
'use client'
import { OrganizationSwitcher } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const Header = () => (
<header>
<OrganizationSwitcher>
<OrganizationSwitcher.OrganizationProfileLink
label="Homepage"
url="/"
labelIcon={<DotIcon />}
/>
</OrganizationSwitcher>
</header>
)
export default Header
'use client'
import { OrganizationProfile } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const OrganizationProfilePage = () => (
<OrganizationProfile path="/organization-profile" routing="path">
<OrganizationProfile.Link label="Homepage" labelIcon={<DotIcon />} url="/" />
</OrganizationProfile>
)
export default OrganizationProfilePage
<script setup lang="ts">
import { OrganizationSwitcher } from '@clerk/vue'
</script>
<template>
<header>
<OrganizationSwitcher>
<OrganizationSwitcher.OrganizationProfileLink label="Homepage" url="/">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
</OrganizationSwitcher.OrganizationProfileLink>
</OrganizationSwitcher>
</header>
</template>
<script setup lang="ts">
import { OrganizationProfile } from '@clerk/vue'
</script>
<template>
<OrganizationProfile>
<OrganizationProfile.Link label="Homepage" url="/">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
</OrganizationProfile.Link>
</OrganizationProfile>
</template>
Reordering default routes
The <OrganizationProfile />
component includes two default menu items: Members
and General
, in that order. You can reorder these default items by setting the label
prop to 'members'
or 'general'
. This will target the existing default item and allow you to rearrange it.
Note that when reordering default routes, the first item in the navigation sidebar cannot be a custom link.
The following example adds a custom page as the first item in the sidenav, followed by a custom link to the homepage, and then the default members and general pages.
'use client'
import { OrganizationSwitcher } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const CustomPage = () => {
return (
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
)
}
const Header = () => (
<header>
<OrganizationSwitcher>
<OrganizationSwitcher.OrganizationProfilePage
label="Custom Page"
url="custom"
labelIcon={<DotIcon />}
>
<CustomPage />
</OrganizationSwitcher.OrganizationProfilePage>
<OrganizationSwitcher.OrganizationProfileLink
label="Homepage"
url="/"
labelIcon={<DotIcon />}
/>
<OrganizationSwitcher.OrganizationProfilePage label="members" />
<OrganizationSwitcher.OrganizationProfilePage label="general" />
</OrganizationSwitcher>
</header>
)
export default Header
'use client'
import { OrganizationProfile } from '@clerk/nextjs'
const DotIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z" />
</svg>
)
}
const CustomPage = () => {
return (
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
)
}
const OrganizationProfilePage = () => (
<OrganizationProfile>
<OrganizationProfile.Page label="Custom Page" url="custom" labelIcon={<DotIcon />}>
<CustomPage />
</OrganizationProfile.Page>
<OrganizationProfile.Link label="Homepage" url="/" labelIcon={<DotIcon />} />
<OrganizationProfile.Page label="members" />
<OrganizationProfile.Page label="general" />
</OrganizationProfile>
)
export default OrganizationProfilePage
<script setup lang="ts">
import { OrganizationSwitcher } from '@clerk/vue'
</script>
<template>
<header>
<OrganizationSwitcher>
<OrganizationSwitcher.OrganizationProfilePage label="Custom Page" url="custom">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
</OrganizationSwitcher.OrganizationProfilePage>
<OrganizationSwitcher.OrganizationProfileLink label="Homepage" url="/">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
</OrganizationSwitcher.OrganizationProfileLink>
<OrganizationSwitcher.OrganizationProfilePage label="members" />
<OrganizationSwitcher.OrganizationProfilePage label="general" />
</OrganizationSwitcher>
</header>
</template>
<script setup lang="ts">
import { OrganizationProfile } from '@clerk/vue'
</script>
<template>
<OrganizationProfile>
<OrganizationProfile.Page label="Custom Page" url="custom">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
<div>
<h1>Custom page</h1>
<p>This is the content of the custom page.</p>
</div>
</OrganizationProfile.Page>
<OrganizationProfile.Link label="Homepage" url="/">
<template #labelIcon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
<path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512z"></path>
</svg>
</template>
</OrganizationProfile.Link>
<OrganizationProfile.Page label="members" />
<OrganizationProfile.Page label="general" />
</OrganizationProfile>
</template>
Feedback
Last updated on