- Interactions with Sitecore
Get the page HTML
Required extension points: any SitecoreAI Page builder extension point
Required SDK packages: client
Required API access: none
- Complete the SDK quick start. In the quick start, you make your first query by running
client.query("application.context").
If your app uses any of the SitecoreAI Page builder extension points, you can retrieve the rendered HTML of the currently open page. The returned HTML is the rendered canvas output, with editing chrome and frames removed, so it reflects what the page looks like to a site visitor rather than the Page builder editing experience.
Ideas for using the page HTML
Consider using this method to build functionalities such as:
- Overlays that analyze or annotate the current page based on its rendered markup.
- Automation workflows that act on the page content without you having to reconstruct it from field data.
- Content-driven actions, such as passing the page HTML to a downstream service.
- Content reuse, such as copying rendered content into another system.
This method only returns the raw rendered HTML of the page. The Marketplace SDK doesn't parse or transform this HTML for you, and it doesn't provide any UI components for displaying it. Your Marketplace app is responsible for handling the returned markup.
To get the page HTML:
-
In the SDK initialization code where you run the
useMarketplaceClienthook, in the Effect Hook, below the"application.context"query, callgetPageHTML(), then save your changes: -
In the SitecoreAI Page builder, open your web browser's console, refresh the page, then open your Marketplace app.
-
In the console, find the log for
Success retrieving page HTMLand inspect the returned value. The value is a string containing the rendered HTML of the current page.
This method requires that the SitecoreAI environment where your app is installed supports the page HTML capability. If the host doesn't support it, the request fails. Make sure to handle this in your app, for example, by using .catch() as shown in the previous example.