This component demonstrates how to wire an Apex method to a component property. The data is automatically retrieved when the component loads and updates reactively.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/trailheadapps/lwc-recipes/llms.txt
Use this file to discover all available pages before exploring further.
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
