User Interface API gives you payloads of Salesforce data and metadata that are structured for building UI. Salesforce uses User Interface API to build Lightning Experience. UI API makes it simple to build a custom user interface according to the rules and permissions inside a Salesforce org because the UI responds to metadata changes at runtime.
Benefits of using UI API :
- Formatted and Localized Display Values
- Layout Types and Form Factors
- Field-level Security and Sharing Rules
- Support declarative changes with no code update
Now, lets talk about using the UI API in LWC. We can use UI API in two ways in LWC:
- Using base components – Its a simple approach which outputs a UI without the need of JS or Apex.
- Using the UI API wire adapters and functions – A flexible approach which outputs no UI and require some JS but no apex.
Using base components
Render record forms with any of these three base components
Using the UI API wire adapters and functions
Query the UI API with wire adapters and functions exposed in the following modules to work with Salesforce data and metadata :
- lightning/ui-list-api (Beta) – Get the records and metadata for a list view.
- lightning/ui-object-info-api – This module is used to get object metadata, and get picklist values.
- lightning/ui-record-api – This module includes wire adapters to record data and get default values to create records.
- lightning/ui-apps-api (Beta) – Get data and metadata for apps displayed in the Salesforce UI.
Note – Not all standard objects are supported by standard ui-api modules. Please find the supported standard objects here.
Hope you liked it. Please find below references for more details: