index.html, calling identify() from a watcher on your signed-in user, and calling reset() in your logout action. This page covers Vue 3 apps built with Vite, and Nuxt apps, which load the tag from nuxt.config instead.
Vue install at a glance
- In Vue with Vite, the tag goes in
index.html. In Nuxt, it goes inapp.headinnuxt.config. - A small helper module lets your code call HelpAlive before the script has loaded.
- A
watchon your signed-in user, withimmediate: true, callsidentify()after login and on every page load. reset()goes in your logout action, for example in a Pinia auth store.- Vue Router changes are tracked by themselves, in history mode and hash mode.
Before you start
- Your project key, from Settings → Setup & API Key. It is public, which means that it is safe to put in your front-end code.
- The store or composable that holds the signed-in user, for example a Pinia
useAuthStore(). - About 10 minutes.
How to install HelpAlive in Vue
1
Add the tag to index.html
Open Replace
index.html at the root of your project and paste the tag before </head>:index.html
YOUR_PROJECT_KEY with your key.2
Add the helper module
Create
src/helpalive.ts. It queues calls made before the script has loaded, and the script replays them in order when it arrives:src/helpalive.ts
3
Call identify() from a watcher on the user
In your root component, watch the signed-in user. Fill the fields from your own user and company objects, and delete the ones your app doesn’t have. Identify users describes each field.
immediate: true makes it run on page load as well as after login:src/App.vue
4
Call reset() in your logout action
Put Also call it wherever your app finds out a session has ended, for example in an HTTP interceptor that sees a
resetUser() in the action that signs the user out:src/stores/auth.ts
401. Don’t call it from the watcher when user is null: the user is null for a moment on every page load, and reset() would close the agent and clear the user’s conversation each time.How to install HelpAlive in Nuxt
1
Add the tag in nuxt.config
Add the script to
app.head, so Nuxt puts it in the head of every page:nuxt.config.ts
2
Call identify() from a client-only plugin
Copy the helper module above to Call
utils/helpalive.ts, then create a plugin whose name ends in .client.ts, so it runs only in the browser:plugins/helpalive.client.ts
resetUser() in your logout function, as in the Vue steps above.Why does the identify code need to run only in the browser?
HelpAlive runs in the browser, andwindow does not exist during server rendering. In Nuxt, the .client.ts suffix keeps the plugin out of the server. The helper module also touches window only inside its functions, so importing it on the server is safe.
Do I need to tell HelpAlive about route changes?
No. HelpAlive records a page view whenever Vue Router changes the address, in history mode and in hash mode. There is nothing to call in a navigation guard.What happens when another user signs in without a reload?
The watcher callsidentify() with the new user when auth.user changes. HelpAlive closes the previous user’s agent first, then opens a fresh one for the new user. Calling reset() in your logout action first is still the right order.
Check that it works
Sign in to your app with a test account, then open Settings → Setup & API Key on the dashboard. The first step, Add HelpAlive to your app, gets a check once HelpAlive has seen your page and a signed-in user. Check it works explains each step. To see what HelpAlive does on a page, adddata-debug to the tag while you test, and remove it before you ship.
Related pages
Identify users
Every identify() field, switching company, and logout.
Verify users
Add a signed token so nobody can pose as another user.
Troubleshooting
The failures that show no error.

