Call Apex Methods

Lightning web components can import methods from Apex classes. The imported methods are functions that the component can call either via @wire or imperatively.

Before you use an Apex method, make sure that there isn’t an easier way to get the data, for example, using a base Lightning component. See Data Guidelines.

Assume that Apex methods provision immutable data, even if it's possible to mutate the data today. It's a best practice to treat all data that a component receives as immutable. To mutate the data, make a shallow copy of the objects you want to mutate. It’s important to understand this concept when working with data. See Data Flow.

The lwc-recipes repo has several components that call Apex methods. Look for components whose names start with apex.

Apex limits are applied per invocation of an Apex method. If your JavaScript code invokes multiple Apex methods via @wire or imperatively, the Apex limits are applied separately to each method call.

See Also