index.html. Then call identify() from the component that holds your signed-in user, and call reset() in your logout code. This page is for React apps built with Vite, Create React App or a similar setup that serves one index.html. Using Next.js? Follow Install HelpAlive in Next.js instead.
Before you start
- Your project key, from Settings → Setup & API Key. It is public, so it is safe to put in your front-end code.
- The component or context that knows the signed-in user, for example an
AuthProvideror auseAuth()hook. - About 10 minutes.
How to install HelpAlive in React
1
Add the tag to index.html
Open Replace
index.html at the root of your project, or public/index.html in Create React App. Paste the tag before </head>:index.html
YOUR_PROJECT_KEY with your key. With the tag in index.html, HelpAlive loads once, when your app starts, and stays loaded on every route.2
Add the helper module
Create In a JavaScript project, name the file
src/helpalive.ts. It lets your components call HelpAlive before the script has finished loading. When the script loads, it replays those calls in order:src/helpalive.ts
helpalive.js. Delete the HelpAliveUser type, the as any, and the type annotations : unknown[] and : HelpAliveUser.3
Call identify() where you hold the signed-in user
Add an effect to the component that holds the user. That way, it runs after login and on every page load while the user stays signed in:The
src/AuthProvider.tsx
createdAt line turns a date into Unix seconds, the only form this field accepts. Fill the rest from your own user and company objects, and delete the fields your app doesn’t have. Identify users describes each field.4
Call reset() in your logout code
Put Also call it wherever your app finds out a session has ended. For example, call it in the response handler that sees a
resetUser() in the function that signs the user out, before you leave the page:src/AuthProvider.tsx
401 and sends the user to the login page. reset() closes the agent and clears its conversation from the browser. The next person on that browser never sees that conversation.Why not call reset() when the user is null?
The user isnull for a moment on every page load, while your app checks the session. A reset() in an else branch of the effect, or in its cleanup, would run on every load. It would close the agent and clear the user’s conversation each time. Call reset() only from code that runs because someone signed out.
Does React StrictMode cause problems?
No. In development, StrictMode runs each effect twice, so your app callsidentify() twice for the same user. A repeated call with the same details is harmless, so nothing changes.
What happens when another user signs in without a reload?
Callidentify() with the new user, which the effect above already does when user changes. HelpAlive closes the previous user’s agent first, then opens a fresh one for the new user. Calling reset() in your logout code first is still the right order.
Do I need to tell HelpAlive about route changes?
No. HelpAlive records a page view whenever your router changes the address, with React Router, TanStack Router or hash routing. There is nothing to call on navigation.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. Remove it before you ship.
Verify users
Verifying users is optional and recommended. Your server signs a token for the signed-in user, and your app passes it toidentify() in place of userId and tenantId. Verify users shows how to create the signing secret and sign the token in your server’s language.
Add the token to what your current-user endpoint returns, for example /api/me. Send that response with Cache-Control: no-store. Then pass the token in the effect from step 3:
src/AuthProvider.tsx
refreshUserToken when a token expires, so you need it only if your tokens have an exp. If your endpoint can’t make a token, for example after an error, pass userId and tenantId as in step 3. Keep resetUser() in your logout code: it also forgets the token.
Next
Identify users
Every identify() field, switching company, and logout.
Verify users
Add a signed token so nobody can use the agent as someone else once Only allow verified users is on.
Troubleshooting
When the agent doesn’t appear.

