# Install Tidio on Vue

Section: Install Tidio

Description: Add the Tidio widget to Vue with Vite, identify logged-in visitors, and control widget visibility during client-side navigation.

Verified against Tidio panel 12.331.0

Last updated: 2026-11-18

Source: https://help.tidio.com/articles/install-vue/

Add Tidio to your Vue app with one script in ` index.html `. You do not need a package for Tidio. Checked with Vue 3.5.45, Vue Router 5.5.1 and Vite 8.3.8.

**In this article, you'll learn:**

- [How to find your Public key](https://help.tidio.com/articles/install-vue/#public-key)
- [How to add the widget to Vue](https://help.tidio.com/articles/install-vue/#install)
- [How to check the installation](https://help.tidio.com/articles/install-vue/#check)
- [How to identify logged-in visitors](https://help.tidio.com/articles/install-vue/#identify-visitors)
- [How to hide the widget on some pages](https://help.tidio.com/articles/install-vue/#hide-on-pages)
- [How to troubleshoot the installation](https://help.tidio.com/articles/install-vue/#troubleshooting)

## Find your Public key

Log in to your Tidio panel and go to **Settings > Developer > Project data**. Click the **Public key** field to select its value, then copy it.

![The Project data page with the Public key field, masked private key and Visit widget SDK documentation button visible](https://help.tidio.com/article-media/install-vue/project-data-public-key.png)

The Public key is part of the script address that every visitor's browser loads, so you can keep it in front-end code. The private key on the same page is different: never put it in your website.

You'll find the same key inside the installation code in **Settings > Live Chat > Installation**, under **Manual install**:

```
<script src="//code.tidio.co/YOUR_PUBLIC_KEY.js" async></script>
```

![Settings > Live Chat > Installation with Manual install selected, the code snippet visible, and the Copy to clipboard button.](https://help.tidio.com/article-media/install-vue/installation-manual-install.png)

## Add the widget to Vue

For a Vue 3 app built with Vite, add your Public key to the ` .env ` file in the project root. Variables that start with ` VITE_ ` are public, and Vite replaces them when you build.

```
VITE_TIDIO_KEY=YOUR_PUBLIC_KEY
```

In ` index.html `, add this script just before the closing ` </body> ` tag. Keep the existing app element and module script. The root HTML document loads the script once, outside the page components that Vue Router swaps.

```
<script src="https://code.tidio.co/%VITE_TIDIO_KEY%.js" async></script>
```

Vite replaces ` %VITE_TIDIO_KEY% ` in HTML with the value from ` .env `. Restart your development server after you change ` .env `, and rebuild your production site.

If an AI coding assistant edits this project for you, give it the prompt from [Install Tidio with an AI coding agent](https://help.tidio.com/articles/install-ai-coding-agents/).

## Check the installation

Open your site in a regular browser window. The chat widget appears in the corner of the page and stays there when you move between pages. Headless and automated browsers may not show the widget, so do not rely on them for this check.

Loading a page with the widget is what activates it. After that, **Settings > Live Chat > Installation** in your Tidio panel says **Chat Widget is installed properly**.

[Video](https://help.tidio.com/article-media/install-vue/walkthrough.mp4)

Silent walkthrough. A demo Vue site with the Tidio chat widget in the corner. The widget stays when the visitor returns to the home page and is hidden on the Checkout page.

## Identify logged-in visitors

This loader replaces the script in ` index.html `, so remove that script first. Create ` src/composables/useTidio.ts ` and call it once from your root ` App.vue `, never from individual pages.

Replace the example identity with your authenticated user's data. If your app loads the session asynchronously, wait for it before you call ` useTidio `. For a signed-out visitor, leave out the ` document.tidioIdentify ` line.

```
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
type Visitor = { distinct_id?: string; email?: string; name?: string; phone?: string }
declare global {
  interface Document { tidioIdentify?: Visitor }
  interface Window {
    tidioChatApi?: {
      on(event: 'ready', callback: () => void): void
      display(visible: boolean): void
      setVisitorData(visitor: Omit<Visitor, 'distinct_id'>): void
      resetVisitor(): void
    }
  }
}

export function useTidio() {
  document.tidioIdentify = { distinct_id: 'unique_id', email: 'contact@mail', name: 'John Doe' }
  const ready = ref(false)
  const onReady = () => { ready.value = true }
  if (window.tidioChatApi) window.tidioChatApi.on('ready', onReady)
  else document.addEventListener('tidioChat-ready', onReady, { once: true })
  const updateVisitor = (visitor: Omit<Visitor, 'distinct_id'>) => {
    if (ready.value) window.tidioChatApi?.setVisitorData(visitor)
  }
  const logOut = () => {
    delete document.tidioIdentify
    if (ready.value) window.tidioChatApi?.resetVisitor()
  }
  const route = useRoute()
  watch([() => route.path, ready], () => {
    if (ready.value) window.tidioChatApi?.display(route.path !== '/checkout')
  }, { immediate: true })
  const script = document.createElement('script')
  script.src = `https://code.tidio.co/${import.meta.env.VITE_TIDIO_KEY}.js`
  script.async = true
  document.body.appendChild(script)
  return { ready, updateVisitor, logOut }
}
```

This root ` src/App.vue ` calls the composable. Keep your own navigation and page content. Call ` updateVisitor ` after a login once ` ready ` is true. It updates visitor data but does not merge conversations. Only the ` document.tidioIdentify ` set before the script loads does that. On logout, ` logOut ` removes the identity and then calls ` resetVisitor `, which restarts the widget.

```
<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
import { useTidio } from './composables/useTidio'
const { ready, updateVisitor, logOut } = useTidio()
</script>
<template>
  <nav><RouterLink to="/">Home</RouterLink> <RouterLink to="/checkout">Checkout</RouterLink></nav>
  <button :disabled="!ready" @click="updateVisitor({ email: 'new@example.com' })">Update visitor</button>
  <button :disabled="!ready" @click="logOut">Log out</button>
  <RouterView />
</template>
```

## Hide the widget on some pages

The composable above already has the route watcher. Replace ` /checkout ` with the route where you want the widget hidden. The watcher waits for the widget's ready event and runs again after every client-side navigation. If you only need this rule, leave out the ` document.tidioIdentify ` line.

```
const route = useRoute()
  watch([() => route.path, ready], () => {
    if (ready.value) window.tidioChatApi?.display(route.path !== '/checkout')
  }, { immediate: true })
```

It calls ` display(false) ` on ` /checkout ` and ` display(true) ` on every other route. Hiding the widget does not stop Flows from triggering. To load the widget only on a list of addresses instead, see [Show the widget only on specific pages](https://help.tidio.com/articles/show-widget-only-on-specific-pages/).

## Troubleshooting

- If the script fails to load, check that ` VITE_TIDIO_KEY ` holds your Public key and not the placeholder ` YOUR_PUBLIC_KEY `, then rebuild.
- If you see two widgets or duplicate script requests, remove one installation. Use either the script in ` index.html ` or the loader, not both.
- If your site uses a Content Security Policy, allow ` code.tidio.co ` in ` script-src ` and add the other hosts from the [Content Security Policy](https://developers.tidio.com/docs/widget-security-policy) page of the developer documentation.
- If an automated browser loads the script but shows no widget, check again in a regular browser window.

## Further reading

- [Install Tidio on your website](https://help.tidio.com/articles/install-website/)
- [Widget SDK](https://help.tidio.com/articles/widget-sdk/)
- [Install Tidio on Nuxt](https://help.tidio.com/articles/install-nuxt/)
- [Install Tidio with an AI coding agent](https://help.tidio.com/articles/install-ai-coding-agents/)
