Skip to main content
For React apps without a framework script component, load the SDK from index.html and consume it with a hook.
1

Add the script to index.html

index.html
For Remix, put the tag in app/root.tsx inside <head> or <body>.
2

Add type declarations

Copy the declaration file from the Types reference into src/types/cashback-hive.d.ts.
3

Create a hook

src/hooks/useCashbackHive.ts
Using useSyncExternalStore (rather than useEffect + useState) handles the case where the SDK finished initialising before your component mounted.
4

Use it

src/App.tsx

Loading the script from JavaScript

If you can’t edit index.html (for example in an embedded widget), inject the tag at runtime. Guard against loading it twice.
data-key is read from document.currentScript when the SDK executes, so set dataset.key before appending the element to the DOM.

Content Security Policy

See Content Security Policy if your app sets one.