# Add the messenger to your app

Install the dimmi messenger in React, Next.js, Vue, Nuxt, Angular, Svelte, or plain JavaScript.

Install one package at the root of your app. Copy `<app_id>` (`wgt_...`) from **Settings → Messengers**. If you self-host, replace `https://trydimmi.com` with your server URL.

<Tabs>
<TabItem label="React">

```bash
npm install @dimmi/react
```

```tsx title="src/main.tsx"

createRoot(document.getElementById("root")!).render(
  <DimmiProvider appId="<app_id>" host="https://trydimmi.com">
    <App />
  </DimmiProvider>,
);
```

</TabItem>
<TabItem label="Next.js">

```bash
npm install @dimmi/nextjs
```

```tsx title="app/layout.tsx"

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Dimmi appId="<app_id>" host="https://trydimmi.com" />
      </body>
    </html>
  );
}
```

</TabItem>
<TabItem label="Vue">

```bash
npm install @dimmi/vue
```

```ts title="src/main.ts"

createApp(App)
  .use(createDimmi({ appId: "<app_id>", host: "https://trydimmi.com" }))
  .mount("#app");
```

</TabItem>
<TabItem label="Nuxt">

```bash
npm install @dimmi/vue
```

```ts title="plugins/dimmi.client.ts"

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(createDimmi({ appId: "<app_id>", host: "https://trydimmi.com" }));
});
```

</TabItem>
<TabItem label="Angular">

```bash
npm install @dimmi/angular
```

```ts title="src/app/app.config.ts"

export const appConfig: ApplicationConfig = {
  providers: [provideDimmi({ appId: "<app_id>", host: "https://trydimmi.com" })],
};
```

</TabItem>
<TabItem label="Svelte">

```bash
npm install @dimmi/svelte
```

```svelte title="src/routes/+layout.svelte"
<script lang="ts">
  import { initDimmi } from "@dimmi/svelte";
  import { onMount } from "svelte";

  let { children } = $props();

  onMount(() => {
    initDimmi({ appId: "<app_id>", host: "https://trydimmi.com" });
  });
</script>

{@render children()}
```

</TabItem>
<TabItem label="JavaScript">

```bash
npm install @dimmi/browser
```

```ts title="src/dimmi.ts"

export const dimmi = loadDimmi({ appId: "<app_id>", host: "https://trydimmi.com" });
```

</TabItem>
<TabItem label="HTML">

```html title="index.html"
<script async src="https://trydimmi.com/widget/v1/loader.js" data-app-id="<app_id>"></script>
```

</TabItem>
</Tabs>

Next, sign in your logged-in users with [Verify customer identity](/developers/messenger/identity-verification/), or trigger chat from custom buttons using the [Messenger JavaScript API](/developers/messenger/javascript-api/).

## Show the unread count

Display an unread badge on your own help button:

```tsx title="src/HelpButton.tsx"

export function HelpButton() {
  const unread = useUnreadCount();
  return <DimmiButton>Chat with us ({unread})</DimmiButton>;
}
```

| Package | How to read unread count |
| --- | --- |
| `@dimmi/react`, `@dimmi/nextjs` | `useUnreadCount()` |
| `@dimmi/vue` | `useUnreadCount()` (`Ref<number>`) |
| `@dimmi/angular` | `DimmiService.unreadCount` (signal) |
| `@dimmi/svelte` | `unreadCount` (store) |
| `@dimmi/browser` | `getDimmi().onUnreadCountChange(fn)` |
| Script tag | `event.detail.count` on the `dimmi:unread` window event |

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
