Lightning Web Component with Salesforce Data

Now the big question is how Lightning Web Component will communicate with Salesforce Data or Lightning Platform Database.
There are many more strategies to get the data from Salesforce via Lightning Web Component. Please read the following strategies to communicate between Lightning Web Component and Lightning Platform Database.

  • Lightning Data Service (LDS)
  • User Interface API(UI API)
  • Import methods from Apex Class


Lightning Data Service(LDS) – It is used to get the data and metadata from Salesforce without calling any Apex Class. It’s offline supported as well as it caches results on the client side. LDS optimizes server calls. It’s used to operate with a single record.

Basically, LDS is built on User Interface API(UI API). LDS supports all features provided by UI API such as CRUD access, Sharing Settings, Layout etc.

Following base components support LDS.

  • lightning-record-form
  • lightning-record-view-form
  • lightning-record-edit-form


User Interface API(UI API) – We can get data and metadata information in a single response by UI API without calling any Apex Class. It is a public and powerful Salesforce API to communicate between Client and Server side. UI API responses support CRUD access, Sharing Settings, Layout Information. We can operate multiple records using UI API. UI API provides powerful adapters such as uiRecordApi, uiListApi etc.

Example of using UI API (in LWC JS file)

import {getRecord, getFieldValue} from ‘lightning/uiRecordApi’;


Import methods from Apex Class – Lastly, we can directly import the method of an Apex Class in LWC JS file to communicate with the Salesforce Records. 
Example of using import methods from an Apex Class
import getContactList from ‘@salesforce/apex/LWC_ContactController.getContactList’;
Now, Salesforce provides the wire adapter and imperative way to communicate with the Salesforce records with the above-mentioned strategies.

9,567 total views, 3 views today

Rating: 5.0/5. From 4 votes.
Please wait...
This entry was posted in Lightning Web Component. Bookmark the permalink.

Leave a Reply