Skip to main content
Installing HelpAlive in a React app means adding one script tag to index.html, calling identify() from the component that holds your signed-in user, and calling 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.

React install at a glance

  • The tag goes in index.html, not in a component, so it loads once for the whole app.
  • A small helper module lets your components call HelpAlive before the script has loaded.
  • identify() runs in a useEffect wherever your app already knows the signed-in user, such as your auth provider.
  • reset() runs in your logout function and when a request comes back signed out, never in an effect.
  • Route changes are tracked by themselves, with React Router or any other router.

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 component or context that knows the signed-in user, for example an AuthProvider or a useAuth() hook.
  • About 10 minutes.

How to install HelpAlive in React

1

Add the tag to index.html

Open index.html at the root of your project (in Create React App it is public/index.html) and paste the tag before </head>:
index.html
Replace YOUR_PROJECT_KEY with your key. Keeping the tag in index.html loads HelpAlive once, as your app starts, on every route.
2

Add the helper module

Create src/helpalive.ts. It lets your components call HelpAlive before the script has finished loading, and the script replays those calls in order when it arrives:
src/helpalive.ts
In a JavaScript project, name the file helpalive.js and delete the type and the as any.
3

Call identify() where you hold the signed-in user

Add an effect to the component that owns the user, so it runs after login and on every page load while the user stays signed in:
src/AuthProvider.tsx
The last line turns a date into Unix seconds, the only form createdAt 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 resetUser() in the function that signs the user out, before you leave the page:
src/AuthProvider.tsx
Also call it wherever your app finds out a session has ended, for example in the response handler that sees a 401 and sends the user to the login page. reset() closes the agent and clears its conversation from the browser, so the next person on that browser starts fresh.
If your app sends a Content Security Policy, add HelpAlive’s sources as Install the script shows in its last step.

Why not call reset() when the user is null?

The user is null 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 identify() is called 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?

Call identify() 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, add data-debug to the tag while you test, and remove it before you ship.

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.
Last modified on October 9, 2026