1. Developer guides

Query the site context

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

    In the quick start, you make your first query by running client.query("application.context").

In the SitecoreAI dashboard widget extension point, you can query the site context to retrieve details about the current site.

To query the site context:

  1. In the SDK initialization code where you run the useMarketplaceClient hook, in the Effect Hook, after the "application.context" query, create a new query, then save your changes:

    // Make a query to retrieve the site context
    client.query("site.context")
      .then((res) => {
        console.log("Success retrieving site.context:", res.data);
      })
      .catch((error) => {
        console.error("Error retrieving site.context:", error);
      });
  2. In a SitecoreAI site dashboard, open your web browser's console, refresh the page, then open your Marketplace app.

  3. In the console, find the log for Success retrieving site.context and inspect the object. The object contains all the details about the current site.

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