JavaScript SDK
Package source:
comprehendly-sdk-js.
Entry: src/index.js (export class Comprehendly).
Not on the public npm registry yet — import from the repo (or vendor the files).
Install and demo
git clone https://github.com/UD-Ultradigital/comprehendly-sdk-js.git
cd comprehendly-sdk-js
cp demo/env.example.js demo/env.js
# set publishableKey; optional pageId, sdkOrigin
npm run demo
# open http://localhost:4173/demo/
Allowlist http://localhost:4173. Open that origin in the browser (not file://).
Client
import { Comprehendly, mountVoiceBridge } from './src/index.js'
const client = new Comprehendly({
publishableKey: 'pk_test_…',
origin: undefined, // browsers set Origin; Node must pass an allowlisted origin
functionsUrl: undefined, // default production Functions URL
anonKey: undefined
})
await client.exchange()
const catalog = await client.catalog.list()
const page = await client.page.get(catalog.forms[0].id)
client.store.set({ fieldName: 'mood', value: 'ok', source: 'user' })
await client.submissions.save({
page_id: page.id || catalog.forms[0].id,
field_values: client.store.values()
})
page.get calls store.loadPage. Bind with store.bind({ elementId }, apply).
Voice iframe
mountVoiceBridge('#voice', {
token: client.accessToken,
pageId,
mode: 'silent',
store: client.store,
sdkOrigin: env.sdkOrigin // optional; default sdk.comprehendly.nz
})
CDN widget
forms.js
mounts hosted iframes (StepCareForms.init). That path does not use FieldStore.