Skip to Content

Salesforce CRT-450: Apex Method Annotation for Lightning Web Component Integration

Learn the correct annotation to use on an Apex method to make it accessible for wiring to a property in a Lightning web component. Discover the difference between @AuraEnabled and @RemoteAction annotations.

Table of Contents

Question

Which annotation should a developer use on an Apex method to make it available to be wired to a property in a Lightning web component?

A. @RemoteAction(cacheable=true)
B. @AuraEnabled
C. @RemoteAction
D. @AuraEnabled(cacheable=true)

Answer

D. @AuraEnabled(cacheable=true)

Explanation

To make an Apex method available for wiring to a property in a Lightning web component, the correct annotation to use is @AuraEnabled. This annotation exposes the Apex method to the Lightning Component framework, allowing it to be called from a Lightning web component.

The cacheable=true parameter is optional but recommended for better performance. When set to true, it enables client-side caching of the method’s return value, reducing the number of server round trips.

@RemoteAction and @RemoteAction(cacheable=true) are incorrect because the @RemoteAction annotation is used to expose an Apex method as a remote action for use in Visualforce pages, not Lightning web components.

Therefore, the correct answer is D. @AuraEnabled(cacheable=true).

Salesforce Certified Platform Developer I CRT-450 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Salesforce Certified Platform Developer I CRT-450 exam and earn Salesforce Certified Platform Developer I CRT-450 certification.