Skip to main content
The Activate widget is the member-facing entry point to cashback. A visitor who isn’t signed in sees a call to action; once they sign in, the widget shows who they are and what they’ve earned. Until a visitor signs in, clicks still go through tracked links and are attributed to you as the publisher — but the member earns nothing. Signing in is what “activates” cashback for them.

What it does

  • Shows a sign-in call to action when no member is signed in.
  • Calls auth.signIn(), which opens the Cashback Hive sign-in window and resolves with the member.
  • Shows the member’s name and pending / confirmed / paid balances.
  • Subscribes to auth:change so it stays correct if sign-in happens elsewhere (another widget, a token restored on load, or sign-in completing in a popup).
  • Offers sign-out via auth.signOut().

Vanilla JavaScript

React / Next.js

Requires the useCashbackHive() hook and the type declarations.
components/activate-widget.tsx

Showing recent activity

Signed-in members can see their recent cashback transactions with member.activity():
Statuses are pending, confirmed, paid and declined. member.activity() throws if no member is signed in, so call it only when auth.isSignedIn() is true.

Design notes

The sign-in window is a popup. auth.signIn() opens a 480×640 popup. Call it from a direct user gesture (a click handler) or browsers will block it. If the popup is blocked anyway, the SDK falls back to a full-page redirect and brings the member back to the current URL afterwards — your widget will then see the member via auth:change on the next page load. Handle rejection. auth.signIn() rejects with Sign-in window was closed if the member closes the popup, or with an error message from the sign-in flow. Reset your button state in a catch/finally. Don’t assume “signed in” means “member loaded”. auth.isSignedIn() only checks for a stored token. member.current() is null until the SDK has fetched the member (which it does in the background on load if a token exists). Subscribe to auth:change rather than polling. Sessions persist across visits. The token lives in localStorage, so a member who signed in last week is still signed in today. If the stored token turns out to be invalid, the SDK signs them out automatically on load. See Members and authentication for the full flow.