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.

Note

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

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.