Install userorbit-js, initialize it once in the browser, and identify users when authentication becomes available.

Install

npm install userorbit-jsBash

Initialize

import { useEffect } from "react";
import userorbit from "userorbit-js";

export function UserorbitInit() {
  useEffect(() => {
    void userorbit.init({ accountId: "YOUR_ACCOUNT_ID" });
  }, []);
  return null;
}TSX

Identify

After sign-in, call userorbit.identify(user.id, { email, name, attributes }). Call logout() on sign-out.

Routes

The SDK detects common History API changes. If an experience does not re-evaluate, call registerRouteChange() in an effect keyed to your router location.

Verify

Use the Network panel and search for the test user in Contacts. Get the Account ID from Settings → Widget installation.

Was this helpful?