index.html and consume it with a hook.
1
Add the script to index.html
index.html
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
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 editindex.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.