Use a browser with ES2022 support, Web Crypto, and local storage, served over HTTPS or localhost. File transfers also use Web Workers and Blob URLs; your Content Security Policy must allow those workers. Internet Explorer is not supported.
This is a browser SDK. In applications with server rendering, import and create
the SDK in a client lifecycle hook, such as React's useEffect or Vue's
onMounted. A dynamic import keeps browser-dependent modules out of server
execution:
async function createBrowserSdk() {
const { default: GeensSdk } = await import('@geens_npo/browser-sdk');
return new GeensSdk('your-client-id', window.location.origin, 'https://geens.com');
}
Call that function only in the browser, after the page body exists. For a
standalone browser script, copy dist/browser-sdk.umd.min.js from the installed
package to your application's public assets:
<script src="/assets/browser-sdk.umd.min.js"></script>
<script>
const sdk = new geensJsSdk('your-client-id', window.location.origin, 'https://geens.com');
</script>
Place those scripts after your page content. The UMD global is geensJsSdk.
The package root exports the ESM constructor and its TypeScript declarations;
internal paths are not public imports. The UMD script path is also exposed.
Runtime library code is bundled. RxJS is installed as a dependency because the
published declarations reference its types.