Option 1: Real API on localhost
The simplest setup is to add your local origin — for examplehttp://localhost:3000 — to the property’s allowed origins in the publisher portal. The SDK then works exactly as it will in production, with real offers and real sign-in.
Remember that the port is part of the origin: http://localhost:3000 and http://localhost:5173 are different origins and both need to be allowed if you use both.
Option 2: Mock mode
Mock mode replaces the network transport with an in-memory one that returns sample data. It’s useful when you’re offline, writing UI tests, or working on a page before your origin has been approved. Enable it with thedata-mock attribute (its presence is enough — no value needed):
What mock mode does
offers.list()andoffers.get()return a fixed catalogue of eight sample brands (Chewy, Nike, Sephora, Expedia, Walmart, HelloFresh, Wayfair, Target) with a mix of percentage and flat cashback, pinned and unpinned, and with and without deep-link support. Search, category,limitandoffsetall work against this set.auth.signIn()resolves after ~300 ms with a sample member (“Sandbox Member”) — no popup is opened.member.activity()returns four sample transactions covering every status (pending,confirmed,paid,declined).- Click URLs point at
https://click.invalid/…, a reserved domain that will never resolve, so you can’t accidentally generate real clicks.openOffer()still emits theclickevent. - Analytics beacons are logged in debug mode instead of being sent.
- Responses are delayed by 80–150 ms to approximate network latency, so loading states are exercised.
What mock mode doesn’t do
- It doesn’t validate your key or origin. A working mock integration doesn’t prove your origin is allowed — test against the real API before launch.
- The sample data is fixed and may not match your property’s real categories or cashback rates.
Debug logging
Adddata-debug (or init({ debug: true })) to log SDK activity to the console, prefixed with [CashbackHive]:
Pointing at a different API
For Cashback Hive-provided staging environments,data-api (or init({ apiBase })) overrides the API base URL. You won’t normally need this.