Identify users
Server-side signing
Generate short-lived, single-use identity tokens.
Payload
Include aud, sub, exp and a unique jti. Name, email, company and bounded attributes are optional.
Signature
Mount once near your application root. The widget reads account changes automatically; logout is explicit.
import { useEffect } from "react";
type User = { id: string; name: string; email: string } | null;
export function WhazzupWidget({ user }: { user: User }) {
useEffect(() => {
window.whazzupSettings = user
? { name: user.name, email: user.email, userId: user.id }
: null;
if (!user) window.whazzup?.("logout");
}, [user]);
useEffect(() => {
const script = document.createElement("script");
script.src = "https://whazzup.io/widget.js";
script.dataset.workspace = "YOUR_WORKSPACE_KEY";
script.async = true;
document.body.appendChild(script);
return () => script.remove();
}, []);
return null;
}Secret handling
Store the value as WHAZZUP_IDENTITY_SECRET in the server environment. Never send it to React or expose it through public build variables.
