Newer Version Available

This content describes an older version of this product. View Latest

@salesforce Modules

LWR sites support several @salesforce modules, which add functionality to Lightning web components at runtime.
Most of the supported modules also support referential integrity, meaning that when a Lightning web component includes a reference to an object or resource, that dependency is respected. For example:
  • If a Lightning web component in your LWR site contains a reference to a supported module, you can’t delete the referenced object without first removing the Lightning web component.
  • If you modify the name of the referenced object or other relevant data in your org, the system automatically updates the reference in your Lightning web component.

For published LWR sites, the system immediately updates the references. However, unpublished sites rely on the source code of the custom component definition, which can take up to 2 hours to update. During this brief window, sometimes it’s not possible to publish your LWR site because the component’s references are temporarily invalid.

Note

See @salesforce Modules in the Lightning Web Components Developer Guide.

Supported Module Description and Limitations
@salesforce/apex Import Apex methods. Calls to Apex behave the same across LWR and Aura sites. If an Apex method signature changes, you must republish your site. Otherwise, the changes can break existing components.
@salesforce/client Get the form factor of the hardware (desktop, tablet, or mobile) that the browser is running on.
@salesforce/contentAssetUrl Import content asset files. Content assets behave the same across LWR and Aura sites. The live site always fetches the latest version of the content asset. And if the name of the content asset changes, the live site doesn’t require you to republish the site.

The URL for the content asset isn’t exactly the same as in Aura sites or in Lightning Experience.

Note

@salesforce/community Get the site ID or the base path. If the base path changes, you’re not required to republish the site.
@salesforce/customPermission Import a custom permission and check whether it’s assigned to the current user. If the assignment of the referenced permission changes, you’re not required to republish the site.
@salesforce/label Reference a label in the org.

Referential integrity isn’t enforced for labels in a published site, as they’re frozen when the site is published. However, when you preview the LWR site in Experience Builder, we always fetch the latest label.

Note

@salesforce/messageChannel Expose the Lightning Message Service API. The Lightning Message Service lets you publish and subscribe to messages across the DOM between different Lightning web components on a page.
@salesforce/resourceUrl Import static resources in your org. Resource URLs behave the same for LWR and Aura sites. The live site always fetches the latest version of the resource. And if you rename the resource, the live site doesn’t require you to republish the site.

The URL for the static resource isn’t exactly the same as in Aura sites or in Lightning Experience.

Note

@salesforce/schema Reference the name of objects, fields, and relationships in your org. If any of these names change, you’re not required to republish the site.
@salesforce/user Get the current user’s ID using the user module’s Id property, or determine whether the current user is a guest using the user module’s isGuest property. If the user is a guest user, the ID is a null value.
@salesforce/userPermission Import a Salesforce permission and check whether it’s assigned to the current user. If the assignment of the referenced permission changes, you’re not required to republish the site.

The @salesforce/apexContinuation module isn’t supported in LWR sites.

Note