Getting started

The Gtmhub SDK exposes methods that enable your UI App to interact with Gtmhub content. It builds on top of the Gtmhub REST API and supports CRUD operations with the main Gtmhub modules:

Additionally the SDK exposes the following functionality:

  • Settings - an API that enables your UI App to work with the settings your app exposes and users fill in on the App Settings screen.
  • Helper Methods - a set of API methods helping you get current context items like the current user, accountId.


NOTE: The UI Apps SDK works only in the context of a Gtmhub application. You can test the functionality it provides when you submit your app to the Gtmhub Marketplace and test the app in your Gtmhub account. For more information on testing your Ui App, see: Build and publish an app.

The Gtmhub UI Apps SDK is available as an npm package, so you can add it in your project. To install the Gtmhub UI Apps SDK in your project follow the steps below:

  1. Navigate to your project's directory, open a terminal and run the following command:
npm install @gtmhub/sdk
  1. Import the library wherever you need it in your JavaScript code:
import gtmhub from "@gtmhub/sdk"


Once you have installed the SDK in your app, before you begin using it you must initialize it using the initializeSdk method. Pass a pluginId object to initializeSdk. The pluginId is the identifier of your UI App.It's a good practice to pass a GUID or similar unique identifier, as this Id will later be used when you submit the app to the Gtmhub Marketplace.

The code sample below demonstrates how you:

  • import the SDK in your JavaScript file
  • initialize it
  • and then use the SDK getCurrentItem helper methods to get the current Gtmhub item your UI app is loaded for

Import the initialization method from the SDK:

import gtmhub from "@gtmhub/sdk";

const sdk = initializeSdk({
  pluginId: "my-plugin-id"

  .then((item) => console.log(`Current item is, ${item}`))

// ...