GSalesforceGyan
← Browse learning guides

LWC

Wire or imperative Apex?

Choose the right way to load data and handle user-driven updates in your component.

By Vishal Verma · Reviewed October 5, 2026

First check whether Lightning Data Service or a UI API adapter can meet the requirement. They provide platform data access without a custom Apex controller.

Use wire for reactive reads

A wired Apex method must be annotated with @AuraEnabled(cacheable=true). Reactive parameters let the framework provision data when those parameters change. Handle both data and error states.

Use imperative calls for explicit control

Call Apex imperatively when an operation should run after a button click, when you need a one-time call, or when the method changes data. Handle the returned promise and show loading, success, and failure states.

Keep security in the design

For custom Apex, enforce record access and object and field permissions using the appropriate platform mechanisms. Hiding a field in the UI does not secure it.

Official reference

Read the Salesforce documentation or Trailhead resource