Skip to content

Widget SDK Reference

This page documents the SDK instance that the platform passes to your widget's init(sdk) function. For installation and connector-calling usage, see the Widget SDK section.

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 — recommended mount target for framework apps (React, Vue, etc.)
getProps<T>()TCurrent widget props (from configuration)
setProps(props)voidUpdate props (emits propsChanged)
getDesignTokens()DesignTokensCurrent community CSS custom properties
getVersionInfo()VersionInfo{ version, gitSha, buildTime }
whenReady()Promise<SDK>Resolves when the SDK is fully initialized
$(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
designTokensChangedRecord<string, string | null>Community branding/theme updates
destroyundefinedWidget removed from DOM
error{ message: string, error?: Error }Module load or initialization error

Next Steps

Gainsight CC Developer Portal