Newer Version Available

This content describes an older version of this product. View Latest

Use Apex While Mobile and Offline

Use Apex-backed wire adapters and imperative Apex in your Lightning web components to call Apex methods in your org.

When you use Apex in an LWC Offline-enabled mobile app, there are considerations to keep in mind so that you make efficient use of network resources, data caching, and handle offline behavior correctly.

First, when the client device is online, Apex-based features of Lightning web components, including Apex continuations, “just work.” You can use all of the features as documented in Call Apex Methods in the Lightning Web Components Developer Guide.

When a client device is offline, Apex-based features can read data that was cached while online, but changes (writing data) can’t be saved back to the server. Nor can a change via Apex methods be enqueued as a draft into the Offline Queue. A Lightning web component that uses Apex must be prepared to handle a network connection error as a normal response, for both reading and writing operations.

Before you make plans to reuse existing Apex custom code in your offline features, read important details about offline caching for Apex in Apex Results Are Separate from Other Primed Data.

Important