Skip to content

Widget Runtime Reference

This page documents the sdk instance the platform passes to your widget's init(sdk) function — a different object from window.WidgetServiceSDK (see SDK Concepts for how the two relate).

This sdk instance has no connectors property

sdk.connectors.execute(...) throws Cannot read properties of undefined (reading 'execute'). See Calling from Widget Code for the correct pattern.

Properties

PropertyTypeDescription
rootShadowRootThe widget's shadow root (mount target)
shadowRootShadowRootAlias for root — the same shadow root reference
documentDocumentGlobal document reference
versionstringSDK version (e.g. "1.5.2")

Methods

MethodReturnsDescription
getContainer()ShadowRootReturns the widget's shadow root — same reference as root/shadowRoot, recommended mount target for framework apps (React, Vue, etc.)
getProps<T>()TCurrent widget props (from configuration)
setProps(props)voidUpdate props (emits propsChanged)
getVersionInfo()VersionInfo{ version, gitSha, buildTime }
whenReady()Promise<SDK>Resolves once initialization completes
$(selector)Element | nullShorthand for shadowRoot.querySelector(selector)
$$(selector)Element[]Shorthand for shadowRoot.querySelectorAll(selector) — returns an array, not a NodeList
on(event, handler)() => voidSubscribe to an event (returns unsubscribe fn)
off(event, handler)voidUnsubscribe from an event
emit(event, data?)voidEmit a custom event

Built-in Events

EventPayloadTrigger
propsChangedRecord<string, unknown>Widget configuration changes
destroyundefinedWidget removed from DOM
error{ message: string, error?: Error }Module load or initialization error

Next Steps

Gainsight CC Developer Portal