Skip to content

Overview

The Community Hub Web SDK (ChWebSdk) is a JavaScript API exposed on community pages. It lets you search content, manage users, subscribe to topics and categories, and interact with the DOM from custom widgets or third-party scripts running in the community frontend.

The SDK is browser-only: all methods that call the backend or DOM throw if run outside a browser environment.

Availability

The SDK is bundled with the community frontend and attached to window (or globalThis) when the destination app loads. There is no separate npm package; you use the global ChWebSdk object on pages that include the community bundle.

javascript
// After the community app has loaded
ChWebSdk.onReady(() => {
  console.log('SDK ready')
})

Quick start

javascript
ChWebSdk.onReady(async () => {
  // Search across all content types
  const results = await ChWebSdk.Content.search('feature request', { limit: 10 })
  console.log(results)

  // Search only ideas
  const ideaInstance = ChWebSdk.Content.Idea()
  const ideas = await ideaInstance.search('dark mode', { limit: 5 })

  // Subscribe to a topic
  await ChWebSdk.Subscription.subscribeTopic('topic-123')

  // Find users by ID
  const users = await ChWebSdk.User.getUsersById(['1', '2', '3'])
})

Summary

AreaMain APIs
Lifecycle / DOMonReady, observeElement, onEvent, loadScript, loadStyle
ContentContent.Article, Question, Conversation, Idea, ProductUpdate + search, like, unlike, vote, unvote, likeReply, unlikeReply
UserUser.search, User.getUsersById
SubscriptionSubscription.subscribeTopic, unsubscribeTopic, subscribeToCategory, unsubscribeFromCategory, getTopicSubscriptionStatus, getCategorySubscriptionStatus

The SDK is initialized when the community frontend loads and is attached to ChWebSdk on the page. Use ChWebSdk.onReady() before calling other APIs if you need to ensure the DOM and context are ready.

What's Next

  • API Reference — DOM utilities, Content, User, Subscription, search options, types, and error handling
  • Examples — search, subscriptions, users, DOM, and script/style loading

Gainsight CC Developer Portal