How to use Salesforce Resources in Lightning Web Component?

Salesforce ResourceSyntax to use
Static Resourceimport sampleResource from '@salesforce/resourceUrl/resourceReference';

Only, we need to enter Static Resource Name in the place of resourceReference and then refer to the property in JS file.If there is a specific namespace in your org, please put the Static Resource Name with the namespace i.e., namespace__StaticResourceName.
Custom Labelimport labelName from '@salesforce/label/labelReference';


Only, we need to enter Custom Label Name with namespace in the place of labelReference and then refer to the property in JS file. If there is no specific namespace in your org, please put the Custom Label Name with default namespace c.
Current User Idimport userId from '@salesforce/user/Id';
SVG ResourceWe can directly write down the SVG in template of the HTML file using tag.
You can also import the SVG from static resource.

9,681 total views, 9 views today

Rating: 4.2/5. From 5 votes.
Please wait...
This entry was posted in Lightning Components. Bookmark the permalink.

Leave a Reply