How to create apps that work even offline

Reworded:

Mobile users often need to stay productive even with limited or no connectivity. When building a canvas app, you can:

  • Open Power Apps Mobile and run apps without network connection.
  • Use the Connection signal object to detect if an app is offline, online, or on a metered connection.
  • Sync data between your device and the server.

If your app connects to Dataverse, offline support is built-in. Power Apps allows you to download data to your device and upload changes back to Dataverse. For apps not using Dataverse, you can use collections with LoadData and SaveData functions for basic offline storage.

Note:

  • Offline capability for canvas apps is available when using the native Power Apps Mobile players on iOS, Android, and Windows.
  • Canvas apps running in web browsers can’t run offline, even on a mobile device.
  • Canvas apps in Teams are limited to 1 MB of data through LoadData and SaveData functions. This limit is suitable for small amounts of text, numbers, and dates, but not for images or other media. More information: LoadData and SaveData function reference.

Enable Offline Support in a Dataverse-Based Canvas App:

For Microsoft Dataverse-based canvas apps, use the built-in offline capability. For more information, see “Set up mobile offline for canvas apps” and “Working with canvas apps offline.” With standard Power Fx formulas, your app can work with Dataverse data online or offline.

Use LoadData and SaveData for All Other Connectors:

You can use LoadData and SaveData functions to store small amounts of data locally. These functions operate on in-memory collections, limited by available app memory, which varies by device and app complexity. They do not automatically resolve merge conflicts when a device comes online. Configuration for saving data and handling reconnection is up to the app creator.

For updates on offline capabilities, refer to this topic and subscribe to the Power Apps blog.

Overview:

When designing offline scenarios, consider how your apps work with data. Apps in Power Apps primarily access data through connectors like SharePoint, Office 365, and Microsoft Dataverse. You can also build custom connectors for any service with a RESTful endpoint. All these connectors use HTTPS over the Internet, so users must be online to access data and services.

Handling Offline Data:

In Power Apps, you can filter, search, sort, aggregate, and manipulate data consistently, regardless of the data source. You can use local collections for offline data management with minimal changes to app logic. Local collections are the primary mechanism for handling offline data.

Build an Offline App:

This example focuses on a Twitter scenario:

  1. Add Twitter to a Blank Phone App:
  • Create a blank canvas app with Phone layout.
  • Add a Twitter data source and connect it.
  1. Collect Existing Tweets:
  • Set the App’s OnStart property to load tweets if online, or load local cache if offline.
  • Save the data locally.
  1. Show Tweets in a Gallery:
  • Insert a gallery and set its Items property to the LocalTweets collection.
  • Add labels to display tweet details.
  1. Show Connection Status:
  • Insert a label to show if the device is connected or offline.
  1. Add a Box to Compose Tweets:
  • Insert a Text input control for new tweets.
  1. Add a Button to Post the Tweet:
  • Set the button’s OnSelect property to post the tweet if online, or save it locally if offline.
  1. Check for New Tweets:
  • Add a Timer control to periodically post any locally saved tweets when the device is online.

Test the App:

  • Open the app on a mobile device with internet connection.
  • Disconnect and reconnect the device to see how the app handles offline and online states.

Summary:

Mobile users often need to work without internet connectivity. Power Apps allows creating canvas apps that can run offline and sync data when reconnected. For Dataverse-connected apps, offline support is built-in. For other apps, LoadData and SaveData functions enable basic offline storage. This example demonstrates creating a Twitter app that works offline, collecting and posting tweets based on the device’s connection status.

You May Also Like