---
title: "Intercom · Nuxt Scripts"
description: "Use Intercom in your Nuxt app."
canonical_url: "https://scripts.nuxt.com/scripts/v0/support/intercom"
meta:
  "og:description": "Use Intercom in your Nuxt app."
  "og:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Intercom%2Cdescription_Use%2BIntercom%2Bin%2Byour%2BNuxt%2Bapp.%2Cheadline_Support%2Cp_Ii9zY3JpcHRzL3YwL3N1cHBvcnQvaW50ZXJjb20i%2Cs_P1Jrb4qXjWP3kCm-.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Intercom · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_Intercom%2Cdescription_Use%2BIntercom%2Bin%2Byour%2BNuxt%2Bapp.%2Cheadline_Support%2Cp_Ii9zY3JpcHRzL3YwL3N1cHBvcnQvaW50ZXJjb20i%2Cs_P1Jrb4qXjWP3kCm-.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Support**

# **Intercom**

[Copy for LLMs](https://scripts.nuxt.com/scripts/v0/support/intercom.md)

[**Intercom**](https://www.intercom.com/) is a customer messaging platform that helps you build better customer relationships.

Nuxt Scripts provides a [**useScriptIntercom**](#usescriptintercom) composable and a headless Facade Component [**ScriptIntercom**](#scriptintercom) component to interact with Intercom.

## ScriptIntercom

The `**ScriptIntercom**` component is headless Facade Component wrapping the [**useScriptIntercom**](#usescriptintercom) composable, providing a simple, performance optimized way to load Intercom in your Nuxt app.

It's optimized for performance by leveraging the [**Element Event Triggers**](https://scripts.nuxt.com/docs/v0/guides/script-triggers#element-event-triggers), only loading Intercom when specific elements events happen.

By default, it will load on the `**click**` DOM event.

### Demo

**Click to load**

Clicking the button to the right will load the Intercom script

### Component API

See the [**Facade Component API**](https://scripts.nuxt.com/docs/v0/guides/facade-components#facade-components-api) for full props, events, and slots.

### Props

- `**trigger**`: The trigger event to load intercom. Default is `**click**`. See [**Element Event Triggers**](https://scripts.nuxt.com/docs/v0/guides/script-triggers#element-event-triggers) for more information.
- `**app-id**`: The Intercom app id.
- `**api-base**`: The Intercom API base URL.
- `**name**`: The name of the user.
- `**email**`: The email of the user.
- `**user-id**`: The user id.
- `**alignment**`: The alignment of the messenger `**left**` or `**right**`. Default is `**right**`.
- `**horizontal-padding**`: The horizontal padding of the messenger. Default is `**20**`.
- `**vertical-padding**`: The vertical padding of the messenger. Default is `**20**`.

See the [**Config Schema**](#config-schema) for full details.

#### **With Environment Variables**

If you prefer to configure your app ID using environment variables.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      intercom: true,
    }
  },
  // you need to provide a runtime config to access the environment variables
  runtimeConfig: {
    public: {
      scripts: {
        intercom: {
          app_id: '', // NUXT_PUBLIC_SCRIPTS_INTERCOM_APP_ID
        },
      },
    },
  },
})
```

.env

```text
NUXT_PUBLIC_SCRIPTS_INTERCOM_APP_ID=<YOUR_APP_ID>
```

### Events

The `**ScriptIntercom**` component emits a single `**ready**` event when Intercom is loaded.

```ts
const emits = defineEmits<{
  ready: [intercom: Intercom]
}>()
```

```vue
<script setup lang="ts">
function onReady(intercom) {
  console.log('Intercom is ready', intercom)
}
</script>

<template>
  <ScriptIntercom @ready="onReady" />
</template>
```

### Intercom API

The component exposes a `**intercom**` instance that you can access the underlying Intercom API.

```vue
<script setup lang="ts">
const intercomEl = ref()
onMounted(() => {
  intercomEl.value.intercom.do('chat:open')
})
</script>

<template>
  <ScriptIntercom ref="intercomEl" />
</template>
```

### Slots

The component provides minimal UI by default, only enough to be functional and accessible. There are a number of slots for you to customize the maps however you like.

**default**

The default slot is used to display content that will always be visible.

**awaitingLoad**

The slot is used to display content while Intercom is not loading.

```vue
<template>
  <ScriptIntercom>
    <template #awaitingLoad>
    <div style="width: 54px; height: 54px; border-radius: 54px; cursor: pointer; background-color: #1972F5;">
      chat!
    </div>
    </template>
  </ScriptIntercom>
</template>
```

**loading**

The slot is used to display content while Intercom is loading.

Tip: You should use the `**ScriptLoadingIndicator**` by default for accessibility and UX.

```vue
<template>
  <ScriptIntercom>
    <template #loading>
      <div class="bg-blue-500 text-white p-5">
        Loading...
      </div>
    </template>
  </ScriptIntercom>
</template>
```

## useScriptIntercom

The `**useScriptIntercom**` composable lets you have fine-grain control over when and how Intercom is loaded on your site.

```ts
const { proxy } = useScriptIntercom({
  app_id: 'YOUR_APP_ID'
})

// examples
proxy.Intercom('show')
proxy.Intercom('update', { name: 'John Doe' })
```

Please follow the [**Registry Scripts**](https://scripts.nuxt.com/docs/v0/guides/registry-scripts) guide to learn more about advanced usage.

### IntercomApi

```ts
export interface IntercomApi {
  Intercom: ((event: 'boot', data?: Input<typeof IntercomOptions>) => void)
  & ((event: 'shutdown') => void)
  & ((event: 'update', options?: Input<typeof IntercomOptions>) => void)
  & ((event: 'hide') => void)
  & ((event: 'show') => void)
  & ((event: 'showSpace', spaceName: 'home' | 'messages' | 'help' | 'news' | 'tasks' | 'tickets' | string) => void)
  & ((event: 'showMessages') => void)
  & ((event: 'showNewMessage', content?: string) => void)
  & ((event: 'onHide', fn: () => void) => void)
  & ((event: 'onShow', fn: () => void) => void)
  & ((event: 'onUnreadCountChange', fn: () => void) => void)
  & ((event: 'trackEvent', eventName: string, metadata?: Record<string, any>) => void)
  & ((event: 'getVisitorId') => Promise<string>)
  & ((event: 'startTour', tourId: string | number) => void)
  & ((event: 'showArticle', articleId: string | number) => void)
  & ((event: 'showNews', newsItemId: string | number) => void)
  & ((event: 'startSurvey', surveyId: string | number) => void)
  & ((event: 'startChecklist', checklistId: string | number) => void)
  & ((event: 'showTicket', ticketId: string | number) => void)
  & ((event: 'showConversation', conversationId: string | number) => void)
  & ((event: 'onUserEmailSupplied', fn: () => void) => void)
  & ((event: string, ...params: any[]) => void)
}
```

### Config Schema

```ts
export const IntercomOptions = object({
  app_id: string(),
  api_base: optional(union([literal('https://api-iam.intercom.io'), literal('https://api-iam.eu.intercom.io'), literal('https://api-iam.au.intercom.io')])),
  name: optional(string()),
  email: optional(string()),
  user_id: optional(string()),
  // customizing the messenger
  alignment: optional(union([literal('left'), literal('right')])),
  horizontal_padding: optional(number()),
  vertical_padding: optional(number()),
})
```

## Example

Using Intercom only in production.

```vue
<script setup lang="ts">
const { proxy } = useScriptIntercom()

// noop in development, ssr
// just works in production, client
function showIntercom() {
  proxy.Intercom('show')
}
</script>

<template>
  <div>
    <button @click="showIntercom">
      Chat with us
    </button>
  </div>
</template>
```

[Edit this page](https://github.com/nuxt/scripts/edit/0.x/docs/content/support/intercom.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/v0/support/intercom.md)

[**Crisp** Show performance-optimized Crisp in your Nuxt app.](https://scripts.nuxt.com/scripts/v0/support/crisp) [**Google Tag Manager** Use Google Tag Manager in your Nuxt app.](https://scripts.nuxt.com/scripts/v0/tracking/google-tag-manager)

**On this page **

- [ScriptIntercom](#scriptintercom)
- [useScriptIntercom](#usescriptintercom)
- [Example](#example)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/v0/support/intercom#webpage","@type":"WebPage","description":"Use Intercom in your Nuxt app.","name":"Intercom","url":"https://scripts.nuxt.com/scripts/v0/support/intercom","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/v0/support/intercom#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/v0/support/intercom"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/v0/support/intercom#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"V0","item":"https://scripts.nuxt.com/scripts/v0","position":3},{"@type":"ListItem","name":"Support","item":"https://scripts.nuxt.com/scripts/v0/support","position":4},{"@type":"ListItem","name":"Intercom","item":"https://scripts.nuxt.com/scripts/v0/support/intercom","position":5}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
