Newer Version Available
@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.
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. |
| @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. |
| @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. |
| @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. |