Use the Wire Service to Get Data
To read Salesforce data, Lightning web components use a reactive wire service. Use @wire
in a component’s JavaScript class to specify a Lightning Data Service (LDS) wire adapter. The wire adapter defines the data shape that the wire service provisions in an immutable stream.
The LDS wire adapters are built on User Interface API or Connect API resources. Each wire adapter provides different Salesforce data and metadata, from individual records and lists of records, to object and layout schema. For example, the lightning/uiRecordApi
module provides wire adapters to get record data or get default data that's needed to create a record. See the Reference section for supported wire adapters.
Before you use a wire adapter, make sure that there isn’t an easier way to get the data. To view, edit, or create records using a form-based interface, consider the lightning-record*form
components.
To improve performance, always use the wire adapter that returns the least amount data that your use case requires. For example, getRecord
returns record data, while getObjectInfo
returns metadata for an object and its fields. To see the data a wire adapter returns, see the Returns section for each wire adapter in lightning/ui*Api Wire Adapters and Functions.
See Also
- lightning/ui*Api Wire Adapters and Functions
- Understand the Wire Service
- Use the Wire Service with Base Components