Introduction

Sometimes, neither the lightning-record-*-form components nor the pre-configured wire adapters suit a particular use case. For example, when you want to customize a single-record data transaction, or perform multi-record operations on a single transaction, Apex is the best choice.

There are several ways to interact with Apex methods from LWC:

  1. Execute the method with @wire to a property
  2. Execute the method with @wire to a function
  3. Call the method imperatively

Limitations

Exposing an Apex method

For an Apex method to be accessible from LWC, it is required:

<aside> ☝ When a method is cacheable, newly added or changed versions of records may not be returned until the cache is refreshed.

</aside>

Parameter types supported

Only the following types are supported for input and output: