---
title: "Tawk.to · Nuxt Scripts"
description: "Load the Tawk.to live chat widget and drive it through a typed proxy, reactive state, and event listeners."
canonical_url: "https://scripts.nuxt.com/scripts/tawk-to"
meta:
  "og:description": "Load the Tawk.to live chat widget and drive it through a typed proxy, reactive state, and event listeners."
  "og:image": "https://scripts.nuxt.com/_og/s/o_05c5409146a28fa9.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Tawk.to · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_05c5409146a28fa9.png"
---

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

**Scripts**

# **Tawk.to**

[Copy for LLMs](https://scripts.nuxt.com/scripts/tawk-to.md)

[**Tawk.to**](https://www.tawk.to/) is a free live chat widget.

[`**useScriptTawkTo()**`](https://scripts.nuxt.com/scripts/tawk-to) loads the widget, types the `**window.Tawk_API**` command surface, and bridges the `**window**` events the embed script dispatches into reactive state and typed listeners.

**Tawk.to**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/tawk-to.ts)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load Tawk.to globally. Alternatively you can use the **useScriptTawkTo** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      tawkTo: {
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

## useScriptTawkTo()

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

```
const { proxy } = useScriptTawkTo()
```

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

## Example

Using Tawk.to in a component.

ConversionButton.vue

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

// noop in development, ssr
// just works in production, client
function handleAction() {
  // use proxy methods here
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>
```

Bundling and proxying are both off. Nobody has verified how the embed script resolves its own API origin, or what live-chat polling connections a proxy would end up in front of, so neither capability is declared rather than guessed at.

Find `**propertyId**` and `**widgetId**` under **Administration Settings → Channels → Chat Widget** in your [**Tawk.to**](http://Tawk.to) dashboard.

```ts
const { proxy } = useScriptTawkTo({
  propertyId: 'YOUR_PROPERTY_ID',
  widgetId: 'YOUR_WIDGET_ID',
})

function openChat() {
  proxy.maximize()
}
```

## Reactive state and events

Tawk's embed script dispatches `**window**` `**CustomEvent**`s (`**tawkLoad**`, `**tawkStatusChange**`, `**tawkChatMaximized**`, …) alongside its documented `**Tawk_API.onXxx = fn**` callback-property API. `**useScriptTawkTo()**` bridges those events into five readonly refs and twenty typed listeners, so you don't have to wire `**window.addEventListener**` yourself:

```vue
<script setup lang="ts">
const { isHidden, isMinimized, isMaximized, chatStatus, unreadCount, onChatStarted, onChatEnded } = useScriptTawkTo({
  propertyId: 'YOUR_PROPERTY_ID',
  widgetId: 'YOUR_WIDGET_ID',
})

onChatStarted(() => {
  console.log('visitor started a chat')
})
onChatEnded(() => {
  console.log('chat ended')
})
</script>

<template>
  <div v-if="!isHidden">
    {{ chatStatus }} · {{ unreadCount }} unread · {{ isMinimized ? 'minimized' : isMaximized ? 'maximized' : 'default' }}
  </div>
</template>
```

`**chatStatus**` is Tawk's own online/away/offline operator status (`**getStatus()**`). It's distinct from `**status**`, the generic script-load state every registry entry exposes.

Every `**onXxx**` listener returns a teardown function for use with `**onScopeDispose**`, mirroring the rest of the registry's event-listener helpers.

The state refs are a single instance shared by every `**useScriptTawkTo()**` call on the page (there's only ever one Tawk widget), not one instance per call.

## Getters

`**proxy**` is fire-and-forget: calls queue until the script loads and replay once it does, but their return value is always discarded, even after loading. That's fine for actions like `**proxy.maximize()**`, which don't return anything meaningful anyway, but it can't carry a real synchronous getter. `**getWindowType**`, `**getStatus**`, `**isChatMaximized**`, `**isChatMinimized**`, `**isChatHidden**`, `**isChatOngoing**`, `**isVisitorEngaged**`, and `**widgetPosition**` are exposed directly on `**useScriptTawkTo()**`'s return value instead, calling straight through to `**window.Tawk_API**`:

```ts
const { getStatus, isChatHidden } = useScriptTawkTo({
  propertyId: 'YOUR_PROPERTY_ID',
  widgetId: 'YOUR_WIDGET_ID',
})

getStatus() // 'online' | 'away' | 'offline' | undefined
isChatHidden() // boolean, false before the widget has loaded
```

## Identifying visitors

`**proxy.visitor = {...}**` doesn't work for the same reason: unhead's script proxy has no `**set**` trap, so a property assignment through it never reaches the real `**Tawk_API**`. Use `**setVisitor()**` instead.

It is pre-load only. Tawk honors `**Tawk_API.visitor**` before the embed script loads and ignores it afterwards, so once the embed has been requested the call warns and does nothing. Change identity after load with `**window.Tawk_API.setAttributes({ name, email, phone, hash })**`.

```ts
const { proxy, setVisitor } = useScriptTawkTo({
  propertyId: 'YOUR_PROPERTY_ID',
  widgetId: 'YOUR_WIDGET_ID',
})

setVisitor({
  name: 'Jane Doe',
  email: 'jane@example.com',
  // HMAC-SHA256 signature for Secure Mode, generated server-side
  hash: visitorHash,
})
proxy.setAttributes({ plan: 'pro' })
proxy.addTags(['vip'])
```

## Switching properties at runtime

```ts
const { proxy } = useScriptTawkTo({
  propertyId: 'YOUR_PROPERTY_ID',
  widgetId: 'YOUR_WIDGET_ID',
})

proxy.switchWidget({ propertyId: 'OTHER_PROPERTY_ID', widgetId: 'OTHER_WIDGET_ID' })
```

`**propertyId**``string`** required **

Your Tawk.to property ID: the first path segment of the widget embed URL \`https://embed.tawk.to/\<propertyId>/\<widgetId>\`.

`**widgetId**``string`** required **

Your Tawk.to widget ID: the second path segment of the widget embed URL \`https://embed.tawk.to/\<propertyId>/\<widgetId>\`.

## Partytown

Do not run [**Tawk.to**](http://Tawk.to) under Partytown. The widget renders DOM overlays (the chat bubble, prechat and full chat panels) directly, and the `**window**` `**CustomEvent**`s the reactive state and listeners depend on aren't configured for worker forwarding.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/tawk-to.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/tawk-to.md)

[**Stripe** Load Stripe.js programmatically or embed a deferred Stripe Pricing Table.](https://scripts.nuxt.com/scripts/stripe) [**TikTok Pixel** Track TikTok conversions with consent, deduplication, and advanced matching.](https://scripts.nuxt.com/scripts/tiktok-pixel)

**On this page **

- [Reactive state and events](#reactive-state-and-events)
- [Getters](#getters)
- [Identifying visitors](#identifying-visitors)
- [Switching properties at runtime](#switching-properties-at-runtime)
- [Partytown](#partytown)

```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/tawk-to#webpage","@type":"WebPage","description":"Load the Tawk.to live chat widget and drive it through a typed proxy, reactive state, and event listeners.","name":"Tawk.to","url":"https://scripts.nuxt.com/scripts/tawk-to","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/tawk-to#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/tawk-to"]}],"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/tawk-to#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":"Tawk.to","item":"https://scripts.nuxt.com/scripts/tawk-to","position":3}]},{"@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.
