Newer Version Available

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

Use Images in an LWC Offline-Enabled Component

Lightning Web Components supports multiple ways of referencing graphics assets in a component. Not all of these methods work when the component runs offline. LWC Offline supports two methods of referencing images in your offline-ready Lightning web components.

The standard methods for referencing images (and other binary assets) in an LWC are:

  • Images uploaded as Files, using the VersionDataUrl field of the latest ContentVersion related to a particular ContentDocument record.
  • Content Assets, using the @salesforce/contentAssetUrl module.
  • Static Resources, using the @salesforce/resourceUrl module.

For LWCs intended to be used offline, consider only the first two options. Static resources aren’t supported for offline use at this time.

Support for offline images requires that both your Salesforce org and your mobile app are updated to the Spring ’23 release (API 57.0) or later.

Note