Implementation
Key Features
Wire to Property
The@wire decorator binds the Apex method directly to the contacts property:
data and error properties.
Accessing Data
Access the returned data throughcontacts.data:
Error Handling
Handle errors throughcontacts.error:
Apex Method Requirements
- Must be annotated with
@AuraEnabled(cacheable=true) - Must be
static - Must use
with sharingfor security - Should include
WITH USER_MODEin SOQL queries for proper security enforcement
When to Use
Use this pattern when:- You need automatic data loading when component initializes
- The Apex method has no parameters
- You want automatic reactive updates
- You need simple access to data and error states
