# Add custom pages and links to the <UserProfile /> component

The [<UserProfile />](https://clerk.com/docs/js-frontend/reference/components/user/user-profile.md) component supports the addition of custom pages and external links to the component's sidenav. It only accepts the following components as children:

- `<UserButton.UserProfilePage />` or `<UserProfile.Page />` to add a [custom page](https://clerk.com/docs/js-frontend/guides/customizing-clerk/adding-items/user-profile.md#add-a-custom-page).
- `<UserButton.UserProfileLink />` or `<UserProfile.Link />` to add a [custom link](https://clerk.com/docs/js-frontend/guides/customizing-clerk/adding-items/user-profile.md#add-a-custom-link).

You can also [reorder default routes](https://clerk.com/docs/js-frontend/guides/customizing-clerk/adding-items/user-profile.md#reorder-default-routes).

## Before you start

Before you start, it's important to understand how the `<UserProfile />` can be accessed:

- As a modal: When a user selects the [<UserButton />](https://clerk.com/docs/js-frontend/reference/components/user/user-button.md) component and then selects the **Manage account** menu item, the `<UserProfile />` will open as a modal by default.
- As a dedicated page: You can embed the `<UserProfile />` component itself in 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:

- `<UserButton />` tab: By default, the `<UserButton />` sets `userProfileMode='modal'`. If you are using the default settings, then you should select this tab.
- `Dedicated page` tab: If you do not want the `<UserProfile />` to open as a modal, then you should select this tab. For these examples, on the `<UserButton />` component, you need to set `userProfileMode='navigation'` and `userProfileUrl='/user-profile'`.

## Add a custom page

To add a custom page to the `<UserProfile />` component, you will need to use one of the following components, depending on the use case mentioned in the [Before you start](https://clerk.com/docs/js-frontend/guides/customizing-clerk/adding-items/user-profile.md#before-you-start) section.

| Use case                                            | Component to use                 |
| --------------------------------------------------- | -------------------------------- |
| `<UserButton />` component                          | `<UserButton.UserProfilePage />` |
| Dedicated page with the `<UserProfile />` component | `<UserProfile.Page />`           |

### Props

`<UserButton.UserProfilePage />` and `<UserProfile.Page />` accept the following props, all of which are **required**:

| Name      | Type               | Description                                                                                                                                                                                                            |
| --------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| label     | string             | The name that will be displayed in the navigation sidenav for the custom page.                                                                                                                                         |
| labelIcon | React.ReactElement | An icon displayed next to the label in the navigation sidenav.                                                                                                                                                         |
| url       | string             | The path segment that will be used to navigate to the custom page. For example, if the <UserProfile /> component is rendered at /user, then the custom page will be accessed at /user/{url} when using path routing. |
| children  | React.ReactElement | The content to be rendered inside the custom page.                                                                                                                                                                     |

### Example

To add custom pages to the `<UserProfile />` component using the [JavaScript SDK](https://clerk.com/docs/reference/javascript/overview.md?sdk=js-frontend), pass the `customPages` property to the `mountUserProfile()` method, as shown in the following example:

filename: main.js
```js
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="user-profile"></div>
  `

const userProfileDiv = document.getElementById('user-profile')

clerk.mountUserProfile(userProfileDiv, {
  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 = ''
      },
    },
  ],
})
```

## Add a custom link

> It is not possible to add custom links to the `<UserProfile />` component when using the [JavaScript SDK](https://clerk.com/docs/reference/javascript/overview.md?sdk=js-frontend). The `mountUserProfile()` method does not have a property for adding custom links.

## Reorder default routes

The `<UserProfile />` component includes two default menu items: `Account` and `Security`, in that order. You can reorder these default items by setting the `label` prop to `'account'` or `'security'`. 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 sidenav cannot be a custom link.

### Example

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 `Account` and `Security` pages.

filename: main.js
```js
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="user-profile"></div>
`

const userProfileDiv = document.getElementById('user-profile')

clerk.mountUserProfile(userProfileDiv, {
  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 = ''
      },
    },
    {
      label: 'account',
    },
    {
      label: 'security',
    },
  ],
})
```

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
