Develop Secure Code
getContent
getContents
getContentRetrieves published content from an enhanced CMS workspace or non-enhanced CMS workspace for an enhanced LWR site in Experience Cloud. This wire adapter can also retrieve published content from a non-enhanced CMS workspace for a non-enhanced LWR site.
To get Salesforce CMS content from an enhanced or non-enhanced CMS workspace for an Aura site, use the lightning/cmsDeliveryApi module’s listContent wire adapter instead.
Note
1import { LightningElement, api, wire } from "lwc";
2import { getContent } from "experience/cmsDeliveryApi";
3import siteId from "@salesforce/site/Id";
4
5export default class GetContentCmsDeliveryApiV2 extends LightningElement {
6 @api contentKey;
7
8 data;
9
10 @wire(getContent, { channelOrSiteId: siteId, contentKeyOrId: "$contentKey" })
11 onGetContent(result) {
12 if (result.data) {
13 this.data = result.data;
14 }
15 }
16}With channelId parameter:
1GET /connect/cms/delivery/channels/${channelId}/contents/${contentKeyOrId}With siteId parameter:
1GET /connect/sites/${siteId}/cms/delivery/contents/${contentKeyOrId}getContent uses this CMS Delivery Content Resource.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
channelOrSiteId | String | The ID for the enhanced LWR site on which you want to use CMS content. | ![]() |
contentKeyOrId | String | The content key or content ID for the CMS content that you want to use on your enhanced LWR site. | ![]() |
data—Managed Content Delivery Documenterror—FetchResponseRelease Preview