1. Developer guides

Initialize the xmc package

Version: 0.4
Before you begin
  • Complete the SDK quick start.

    In the quick start, you initialize the Marketplace SDK client package, which is required for every Marketplace app.

The Marketplace SDK xmc package is optional by default, but you must initialize it if your app needs to interact with SitecoreAI APIs.

To initialize the xmc package:

  1. If you haven't installed the package yet, install it by running the following command in your terminal:

    npm install @sitecore-marketplace-sdk/xmc
  2. In the useMarketplaceClient.ts hook, import XMC from the package:

    import { XMC } from "@sitecore-marketplace-sdk/xmc";
  3. In the same file, in the getMarketplaceClient function, in the config variable, add XMC to the list of modules, then save your changes:

    const config = {
      target: window.parent,
      modules: [XMC], // add the module
    };

You can now start making queries and mutations that require access to SitecoreAI APIs, for example, make GraphQL queries. For a full list of operations, refer to the reference documentation.

Important

Requests to SitecoreAI APIs only work in the SitecoreAI environments where your app is installed.

All requests to SitecoreAI APIs must contain the Context ID of your SitecoreAI environment, which you can retrieve from the application context. For code examples, see Make a GraphQL query.

If you have suggestions for improving this article, let us know!