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 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 resources and live in the lightning/ui*Api modules. Each wire adapter provides different Salesforce data and metadata, from individual records and lists of records, to object and layout schema.

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