Creates the SDK instance and assigns it to window.CashbackHive. If an instance already exists (the script was loaded twice), the second load does nothing.
Reads data-* attributes from its own <script> tag. If data-key is present it calls init() immediately — this is auto-initialisation. If data-key is absent, nothing happens until you call CashbackHive.init() yourself.
During init() it sends an sdk_loaded analytics beacon, and if a member token is already in localStorage from a previous visit it fetches the member in the background.
Resolves the ready promise, then dispatches cbh:ready on window and calls window.onCashbackHiveReady if you defined one.
init() only runs once. Calling it a second time is ignored (and logged in debug mode).
You must not call SDK methods before initialisation. Methods throw [CashbackHive] call init({ key }) first, or set data-key on the script tag if you do. Pick whichever readiness signal fits your code.
A CustomEvent on window. The SDK is on event.detail.sdk.
window.addEventListener("cbh:ready", (event) => { const sdk = event.detail.sdk; // safe to use sdk here});
Events only reach listeners that are registered before the event fires. If your listener might attach late, combine it with the initialized check below.
CashbackHive.ready is a promise that resolves after init() completes. It’s convenient in async code, but it only exists once sdk.js has executed, so guard against the script not having loaded yet:
Define a global function before the script loads and the SDK will call it with the instance. Useful in environments where you can’t add event listeners easily (for example some tag managers).
Always load sdk.js with async (or your framework’s equivalent, such as Next.js’s strategy="afterInteractive"). The SDK doesn’t block rendering and has no dependency on DOM content being parsed.Because the script is async, its execution order relative to your own scripts is not guaranteed — which is exactly why you should use cbh:ready rather than assuming window.CashbackHive exists.
Load the SDK once, at the application root (root layout, index.html, _app), not inside individual routes or components. Client-side navigation doesn’t reload the page, so the SDK stays initialised and cbh:ready doesn’t fire again. Components that mount later should use the initialized check shown above.
sdk.js is served with Cache-Control: public, max-age=300, stale-while-revalidate=86400. Browsers cache it for five minutes and may serve a stale copy for up to a day while revalidating in the background, so SDK updates roll out to visitors within minutes without any change on your side.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Cashback Hive","description":"Cashback SDK documentation for publishers. Add cashback offers, member sign-in and tracked affiliate links to any website with one script tag.","colors":{"primary":"#6b5bd6","light":"#8f82e6","dark":"#5154c4"},"logo":{"light":"https://mintcdn.com/cashback-hive-cebb35eb/EX8Nvw5J3Q3n7Cf5/logo/light.svg?fit=max\u0026auto=format\u0026n=EX8Nvw5J3Q3n7Cf5\u0026q=85\u0026s=d60ac62409de6513d36f9426615dfa46","dark":"https://mintcdn.com/cashback-hive-cebb35eb/EX8Nvw5J3Q3n7Cf5/logo/dark.svg?fit=max\u0026auto=format\u0026n=EX8Nvw5J3Q3n7Cf5\u0026q=85\u0026s=b10b94896e9644d7efe58acf6a3d2bd6","href":"https://www.cashbackhive.com"},"favicon":"https://mintcdn.com/cashback-hive-cebb35eb/EX8Nvw5J3Q3n7Cf5/favicon.svg?fit=max\u0026auto=format\u0026n=EX8Nvw5J3Q3n7Cf5\u0026q=85\u0026s=655f12351170cdcebecec5ca0bc06064","appearance":{"default":"light"},"background":{"color":{"light":"#ffffff","dark":"#121212"}},"navbar":{"links":[{"href":"https://www.cashbackhive.com","label":"cashbackhive.com"}]},"footer":{"socials":{"x":"https://twitter.com/cashbackhive","facebook":"https://facebook.com/cashbackhive","instagram":"https://instagram.com/cashbackhive"},"links":[{"header":"Company","items":[{"label":"About Us","href":"https://www.cashbackhive.com/about"},{"label":"How It Works","href":"https://www.cashbackhive.com/how-it-works"},{"label":"FAQ","href":"https://www.cashbackhive.com/faq"},{"label":"Contact","href":"https://www.cashbackhive.com/contact"}]},{"header":"Legal","items":[{"label":"Privacy Policy","href":"https://www.cashbackhive.com/privacy"},{"label":"Terms of Service","href":"https://www.cashbackhive.com/terms"}]}]},"seo":{"metatags":{"canonical":"https://developer.cashbackhive.com/sdk","og:site_name":"Cashback Hive","og:type":"website","og:locale":"en_US","twitter:card":"summary_large_image","twitter:site":"@cashbackhive","author":"Cashback Hive","robots":"index, follow, max-image-preview:large, max-snippet:-1"},"organization":{"id":"https://www.cashbackhive.com/#organization","name":"Cashback Hive","url":"https://www.cashbackhive.com","logo":"https://developer.cashbackhive.com/sdk/logo/light.svg","sameAs":["https://twitter.com/cashbackhive","https://facebook.com/cashbackhive","https://instagram.com/cashbackhive"]},"indexing":"navigable"},"fonts":{"family":"Vend Sans"},"thumbnails":{"preset":"classic","appearance":"light","surface":"brand","eyebrow":{"source":"group","style":"pill"}},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"cashback-hive-cebb35eb","hasAudioNarration":false,"actualSubdomain":"cashback-hive-cebb35eb","customDomains":["developer.cashbackhive.com"],"gitSource":{"type":"artifacts","owner":"prod","repo":"fe377fdd2788f428c9d39da0","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6ae77645840fe1a6751d61ae"},"chroma":{"latestBuiltDeploymentHistoryId":"6ae77d61ee8b55c46b4c1d24","collectionId":"1cd527a0-c780-45ca-8a07-a95f24d1c1e0","liveDeploymentHistoryId":"6ae77d61ee8b55c46b4c1d24","schemaVersion":"v3"},"entitlements":{},"buildId":"6ae77f8d17411a97942e8496","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"API reference","count":8},{"language":"default","tag":"Guides","count":5},{"language":"default","tag":"Get started","count":4},{"language":"default","tag":"Installation","count":4},{"language":"default","tag":"Widgets","count":3},{"language":"default","tag":"Resources","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[],"page":{"pagePath":"concepts/lifecycle","slug":"/concepts/lifecycle","pageMetadata":{"title":"Lifecycle and readiness","description":"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.","href":"/concepts/lifecycle"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`initialisation-sequence`,children:`Initialisation sequence`}),`\n`,_jsxs(_components.p,{children:[`When `,_jsx(_components.code,{children:`sdk.js`}),` executes it:`]}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Creates the SDK instance and assigns it to `,_jsx(_components.code,{children:`window.CashbackHive`}),`. If an instance already exists (the script was loaded twice), the second load does nothing.`]}),`\n`,_jsxs(_components.li,{children:[`Reads `,_jsx(_components.code,{children:`data-*`}),` attributes from its own `,_jsx(_components.code,{children:`\u003cscript>`}),` tag. If `,_jsx(_components.code,{children:`data-key`}),` is present it calls `,_jsx(_components.code,{children:`init()`}),` immediately — this is `,_jsx(_components.strong,{children:`auto-initialisation`}),`. If `,_jsx(_components.code,{children:`data-key`}),` is absent, nothing happens until you call `,_jsx(_components.a,{href:`/reference/configuration#manual-initialisation`,children:_jsx(_components.code,{children:`CashbackHive.init()`})}),` yourself.`]}),`\n`,_jsxs(_components.li,{children:[`During `,_jsx(_components.code,{children:`init()`}),` it sends an `,_jsx(_components.code,{children:`sdk_loaded`}),` analytics beacon, and if a member token is already in `,_jsx(_components.code,{children:`localStorage`}),` from a previous visit it fetches the member in the background.`]}),`\n`,_jsxs(_components.li,{children:[`Resolves the `,_jsx(_components.code,{children:`ready`}),` promise, then dispatches `,_jsx(_components.code,{children:`cbh:ready`}),` on `,_jsx(_components.code,{children:`window`}),` and calls `,_jsx(_components.code,{children:`window.onCashbackHiveReady`}),` if you defined one.`]}),`\n`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`init()`}),` only runs once. Calling it a second time is ignored (and logged in debug mode).`]})}),`\n`,_jsx(Heading,{level:`2`,id:`knowing-when-the-sdk-is-ready`,children:`Knowing when the SDK is ready`}),`\n`,_jsxs(_components.p,{children:[`You `,_jsx(_components.strong,{children:`must not`}),` call SDK methods before initialisation. Methods throw `,_jsx(_components.code,{children:`[CashbackHive] call init({ key }) first, or set data-key on the script tag`}),` if you do. Pick whichever readiness signal fits your code.`]}),`\n`,_jsxs(Heading,{level:`3`,id:`cbhready-event-recommended`,children:[_jsx(_components.code,{children:`cbh:ready`}),` event (recommended)`]}),`\n`,_jsxs(_components.p,{children:[`A `,_jsx(_components.code,{children:`CustomEvent`}),` on `,_jsx(_components.code,{children:`window`}),`. The SDK is on `,_jsx(_components.code,{children:`event.detail.sdk`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addEventListener`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cbh:ready\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` sdk`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`detail`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // safe to use sdk here`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Events only reach listeners that are registered `,_jsx(_components.strong,{children:`before`}),` the event fires. If your listener might attach late, combine it with the `,_jsx(_components.code,{children:`initialized`}),` check below.`]}),`\n`,_jsxs(Heading,{level:`3`,id:`initialized-property`,children:[_jsx(_components.code,{children:`initialized`}),` property`]}),`\n`,_jsx(_components.p,{children:`A synchronous boolean on the instance. Use it to handle the “already ready” case:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` whenReady`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` sdk`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`CashbackHive`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`initialized`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {};`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` handler`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`detail`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`addEventListener`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cbh:ready\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`once:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`removeEventListener`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cbh:ready\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This pattern is what you want in components that mount after page load, such as a route that’s navigated to client-side.`}),`\n`,_jsxs(Heading,{level:`3`,id:`ready-promise`,children:[_jsx(_components.code,{children:`ready`}),` promise`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`CashbackHive.ready`}),` is a promise that resolves after `,_jsx(_components.code,{children:`init()`}),` completes. It’s convenient in `,_jsx(_components.code,{children:`async`}),` code, but it only exists once `,_jsx(_components.code,{children:`sdk.js`}),` has executed, so guard against the script not having loaded yet:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`CashbackHive`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ready`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`3`,id:`oncashbackhiveready-callback`,children:[_jsx(_components.code,{children:`onCashbackHiveReady`}),` callback`]}),`\n`,_jsx(_components.p,{children:`Define a global function before the script loads and the SDK will call it with the instance. Useful in environments where you can’t add event listeners easily (for example some tag managers).`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`html`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`html`,children:_jsxs(_components.code,{language:`html`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`onCashbackHiveReady`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` sdk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`offers`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`list`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` src`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://sdk.cashbackhive.com/sdk.js\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` data-key`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cbh_pk_…\"`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`2`,id:`script-loading-and-async`,children:[`Script loading and `,_jsx(_components.code,{children:`async`})]}),`\n`,_jsxs(_components.p,{children:[`Always load `,_jsx(_components.code,{children:`sdk.js`}),` with `,_jsx(_components.code,{children:`async`}),` (or your framework’s equivalent, such as Next.js’s `,_jsx(_components.code,{children:`strategy=\"afterInteractive\"`}),`). The SDK doesn’t block rendering and has no dependency on DOM content being parsed.`]}),`\n`,_jsxs(_components.p,{children:[`Because the script is `,_jsx(_components.code,{children:`async`}),`, its execution order relative to your own scripts is not guaranteed — which is exactly why you should use `,_jsx(_components.code,{children:`cbh:ready`}),` rather than assuming `,_jsx(_components.code,{children:`window.CashbackHive`}),` exists.`]}),`\n`,_jsx(Heading,{level:`2`,id:`single-page-applications`,children:`Single-page applications`}),`\n`,_jsxs(_components.p,{children:[`Load the SDK `,_jsx(_components.strong,{children:`once`}),`, at the application root (root layout, `,_jsx(_components.code,{children:`index.html`}),`, `,_jsx(_components.code,{children:`_app`}),`), not inside individual routes or components. Client-side navigation doesn’t reload the page, so the SDK stays initialised and `,_jsx(_components.code,{children:`cbh:ready`}),` doesn’t fire again. Components that mount later should use the `,_jsx(_components.code,{children:`initialized`}),` check shown above.`]}),`\n`,_jsx(Heading,{level:`2`,id:`caching`,children:`Caching`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`sdk.js`}),` is served with `,_jsx(_components.code,{children:`Cache-Control: public, max-age=300, stale-while-revalidate=86400`}),`. Browsers cache it for five minutes and may serve a stale copy for up to a day while revalidating in the background, so SDK updates roll out to visitors within minutes without any change on your side.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Lifecycle and readiness","description":"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.","href":"/concepts/lifecycle"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Initialisation sequence","slug":"initialisation-sequence","depth":2,"children":[]},{"title":"Knowing when the SDK is ready","slug":"knowing-when-the-sdk-is-ready","depth":2,"children":[{"title":"cbh:ready event (recommended)","slug":"cbhready-event-recommended","depth":3,"children":[]},{"title":"initialized property","slug":"initialized-property","depth":3,"children":[]},{"title":"ready promise","slug":"ready-promise","depth":3,"children":[]},{"title":"onCashbackHiveReady callback","slug":"oncashbackhiveready-callback","depth":3,"children":[]}]},{"title":"Script loading and async","slug":"script-loading-and-async","depth":2,"children":[]},{"title":"Single-page applications","slug":"single-page-applications","depth":2,"children":[]},{"title":"Caching","slug":"caching","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"cashback-hive-cebb35eb","siteName":"Cashback Hive","title":"Lifecycle and readiness - Cashback Hive","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-01T18:06:08.774Z","originalFileLocation":"concepts/lifecycle.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Cashback Hive\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow, max-image-preview:large, max-snippet:-1\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Lifecycle and readiness - Cashback Hive\">\u003cmeta data-mint-head property=\"og:description\" content=\"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Cashback Hive\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://developer.cashbackhive.com/sdk/concepts/lifecycle\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://cashback-hive-cebb35eb.mintlify.app/_mintlify/api/og/v2?division=Get+started\u0026amp;title=Lifecycle+and+readiness\u0026amp;description=Understand+how+the+Cashback+Hive+SDK+initialises%2C+the+three+ways+to+detect+when+it+is+ready%2C+and+how+to+avoid+race+conditions+in+your+integration.\u0026amp;theme=cabb3e0c01942118665bd7c6\u0026amp;signature=32aac0a6e74726f2e832d3e5f90b61bbad8061b8504aaa6ed6806edc4de316a0\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Lifecycle and readiness - Cashback Hive\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://cashback-hive-cebb35eb.mintlify.app/_mintlify/api/og/v2?division=Get+started\u0026amp;title=Lifecycle+and+readiness\u0026amp;description=Understand+how+the+Cashback+Hive+SDK+initialises%2C+the+three+ways+to+detect+when+it+is+ready%2C+and+how+to+avoid+race+conditions+in+your+integration.\u0026amp;theme=cabb3e0c01942118665bd7c6\u0026amp;signature=32aac0a6e74726f2e832d3e5f90b61bbad8061b8504aaa6ed6806edc4de316a0\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/cashback-hive-cebb35eb/ihdbgeb38IO54b_Q/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Cashback Hive\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6b5bd6\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en_US\">\u003cmeta data-mint-head name=\"author\" content=\"Cashback Hive\">\u003clink data-mint-head rel=\"canonical\" href=\"https://developer.cashbackhive.com/sdk/concepts/lifecycle\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/concepts/lifecycle.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.cashbackhive.com/#organization\",\"name\":\"Cashback Hive\",\"url\":\"https://www.cashbackhive.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://developer.cashbackhive.com/sdk/logo/light.svg\"},\"sameAs\":[\"https://twitter.com/cashbackhive\",\"https://facebook.com/cashbackhive\",\"https://instagram.com/cashbackhive\"]},{\"@type\":\"WebSite\",\"@id\":\"https://developer.cashbackhive.com/sdk#website\",\"name\":\"Cashback Hive\",\"url\":\"https://developer.cashbackhive.com/sdk\",\"publisher\":{\"@id\":\"https://www.cashbackhive.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle#webpage\",\"url\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle\",\"name\":\"Lifecycle and readiness\",\"description\":\"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\",\"dateModified\":\"2026-11-01T18:06:08.774Z\",\"isPartOf\":{\"@id\":\"https://developer.cashbackhive.com/sdk#website\"},\"breadcrumb\":{\"@id\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Get started\",\"item\":\"https://developer.cashbackhive.com/sdk/index\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lifecycle and readiness\",\"item\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle#article\",\"headline\":\"Lifecycle and readiness\",\"name\":\"Lifecycle and readiness\",\"description\":\"Understand how the Cashback Hive SDK initialises, the three ways to detect when it is ready, and how to avoid race conditions in your integration.\",\"url\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle\",\"mainEntityOfPage\":{\"@id\":\"https://developer.cashbackhive.com/sdk/concepts/lifecycle#webpage\"},\"dateModified\":\"2026-11-01T18:06:08.774Z\",\"publisher\":{\"@id\":\"https://www.cashbackhive.com/#organization\"},\"isPartOf\":{\"@id\":\"https://developer.cashbackhive.com/sdk#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Cashback Hive\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Cashback Hive","nav":{"global":null,"groups":[{"group":"Get started","pages":[{"title":"Cashback SDK","sidebarTitle":"Overview","href":"/index"},{"title":"Quickstart","href":"/quickstart"},{"title":"Keys and allowed origins","description":"Learn how Cashback Hive publishable keys and allowed origins work, why they are safe to ship in the browser, and which credentials to keep server-side.","href":"/concepts/keys-and-origins"},{"title":"Lifecycle and readiness","href":"/concepts/lifecycle"}]},{"group":"Installation","pages":[{"title":"Plain HTML","description":"Install the Cashback Hive SDK on a static or server-rendered HTML site with a single script tag, then call the API once the cbh:ready event fires.","href":"/installation/html"},{"title":"Next.js","href":"/installation/nextjs"},{"title":"React (Vite, CRA, Remix)","href":"/installation/react"},{"title":"Google Tag Manager","href":"/installation/gtm"}]},{"group":"Widgets","pages":[{"title":"Widgets overview","href":"/widgets/overview"},{"title":"Offers widget","href":"/widgets/offers"},{"title":"Activate widget","href":"/widgets/activate"}]},{"group":"Guides","pages":[{"title":"Members and authentication","href":"/guides/members-and-auth"},{"title":"Click tracking","href":"/guides/click-tracking"},{"title":"Local development","href":"/guides/local-development"},{"title":"Content Security Policy","href":"/guides/content-security-policy"},{"title":"Troubleshooting","href":"/guides/troubleshooting"}]},{"group":"API reference","pages":[{"title":"Configuration","href":"/reference/configuration"},{"title":"Offers","href":"/reference/offers"},{"title":"Member","href":"/reference/member"},{"title":"Auth","href":"/reference/auth"},{"title":"Tracking","href":"/reference/tracking"},{"title":"Events","href":"/reference/events"},{"title":"Types","href":"/reference/types"},{"title":"Errors","href":"/reference/errors"}]},{"group":"Resources","pages":[{"title":"Changelog","href":"/changelog"}]}]},"basePath":"","title":"Lifecycle and readiness - Cashback Hive","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":[],"chunks":[]}