Rendered Widget HTML now available in GraphQL Storefront API
June 22nd, 2021 at 2:33 PM
API
Announcement
Storefront API
You may now fetch the rendered HTML of widgets created via Widgets API or Page Builder.
To get the content, you’ll need to provide a page type, and the ID for the page (if necessary). In the response, you’ll get a list of all the regions on that page, and the HTML of the widgets within those regions. This response can be used to inject Widget content into a headless storefront, or in any other situation where you need to flexibly access the content.
Here’s an example query:
# Get the widget HTML for the home page query getHomePageContentWidgets { site { content { renderedRegionsByPageType(pageType: HOME) { regions { name html } } } } }
Did you like this update?
{error_message}
Leave your name and email so that we can reply to you (both fields are optional):
Thanks for your feedback!