Skip to content

Widget SDK

The SDK is a JavaScript library that your widget code uses to call connectors — the secure backend proxies that connect widgets to external APIs. Instead of making API calls directly from the browser (which would expose your credentials), you use the SDK to route requests through the platform.

The SDK is loaded automatically by Customer Community and exposed on window.WidgetServiceSDK inside every widget — no script tag is required. Use it like this:

html
<script>
  // Async IIFE required — top-level await is not available in plain <script> tags
  (async () => {
    const sdk = new window.WidgetServiceSDK();

    const data = await sdk.connectors.execute({
      permalink: "weather-api",
      method: "GET",
      queryParams: { q: "Warsaw" }
    });

    console.log(data);
  })();
</script>

Constructor options

Pass an optional configuration object when creating the SDK instance:

javascript
const sdk = new window.WidgetServiceSDK({
  timeout: 15000,
  headers: { "X-Custom-Header": "value" }
});
OptionTypeDefaultDescription
headersRecord<string, string>{}Headers included with every request
timeoutnumber30000Request timeout in milliseconds

Next Steps

Gainsight CC Developer Portal