> ## Documentation Index
> Fetch the complete documentation index at: https://embedded-apps.rollout.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Show apps on a contact

> Mount the apps a user turned on, on your contact page, with mountEmbeddedApps().

![A contact page with the Apps tab highlighted, showing two apps.](https://mintcdn.com/rollout-embedded-apps/I1umzqggy_PAdPKI/images/contact-page.png?fit=max\&auto=format\&n=I1umzqggy_PAdPKI\&q=85\&s=f08ba06c50cce3f2d3be7458f3568f7e)

mountEmbeddedApps() fills the element you give it with the user's apps, stacked, each under its name.

## Load the library

```js theme={null}
import { mountEmbeddedApps, mountEmbeddedAppMarketplace } from "https://universal.rollout.com/api/embedded-apps/host-v1.js";
```

The library is plain JavaScript with no dependencies, loaded as a module. It's
served at a stable URL and updated by Rollout, so you get fixes without
redeploying.

## Mount the apps

Pick the element the apps should fill, such as the body of an Apps tab, and
mount them there for the contact on screen:

```js theme={null}
import { mountEmbeddedApps } from "https://universal.rollout.com/api/embedded-apps/host-v1.js";

const empty = document.createElement("p");
empty.innerHTML = 'No apps yet. <a href="/settings/apps">Browse the marketplace</a>';

const apps = mountEmbeddedApps(document.querySelector("#apps"), {
  marketplaceId: "YOUR_MARKETPLACE_ID",
  record: { type: "person", id: contactId },
  getToken: ({ record }) =>
    fetch(`/rollout/apps-token?personId=${encodeURIComponent(record.id)}`).then((r) => r.text()),
  emptyState: empty, // optional
  onAppsLoaded: (loaded) => {}, // optional
  onError: ({ code, message }) => {}, // optional
});

// In a single-page app, on another contact:
apps.setRecord({ type: "person", id: nextContactId });
// When the page goes away:
apps.unmount();
```

Each enabled app is shown under its name, stacked, and each app's frame takes
the height its app reports. An app is shown only after its page answers
Rollout's handshake, so an app that fails to load never leaves an empty box.

The apps render in an iframe from Rollout's origin, inside a shadow root, so
your page's styles don't reach it.

### Options

| Option | |
| - | - |
| `marketplaceId` | Your marketplace id. Required. |
| `record` | `{ type: "person", id: string }`: the contact on screen, by your id for it. Required. |
| `getToken` | `({ record }) => Promise<string>`: returns a user token with `embed:render` for `record`. Called on mount, on each `setRecord`, and when Rollout refuses a token. Required. |
| `minHeight`, `maxHeight` | Bounds for each app's height, in px. None by default: each app takes its own height. An app frame first shows at `minHeight`, until its app reports a height. Changing either needs a new mount. |
| `emptyState` | A node shown in place of the apps when the user has none on. It sits in your page, so your styles apply to it. |
| `onAppsLoaded` | `(apps: { id, name }[]) => void`: the apps shown, empty when none. |
| `onError` | `({ code, message }) => void`: see [Errors](https://embedded-apps.rollout.com/reference/errors.md). |

### Handle methods

| Method | |
| - | - |
| `setRecord(record)` | Shows another contact without remounting. |
| `refresh()` | Renders the apps again, for example after the user turns one on. |
| `unmount()` | Removes the apps and their listeners. If your page removes the container without calling it, the component cleans up its listener on its own, but call it when you can. |

## Your page's Content Security Policy

If your pages send a `Content-Security-Policy`, allow Rollout's origin for the
library, the Rollout frame, the marketplace's requests and the app icons,
which Rollout hosts:

```
script-src  'self' https://universal.rollout.com;
frame-src   https://universal.rollout.com;
connect-src 'self' https://universal.rollout.com;
img-src     'self' https://universal.rollout.com;
```

Your page loads nothing from a publisher's servers. The apps load inside the
Rollout frame, so your policy doesn't need to list them.

## Next

[Add the marketplace](https://embedded-apps.rollout.com/build/add-the-marketplace.md), so users can turn apps on.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.