Overview
By default, UnifyApps applications detect connectivity loss automatically via the browser/OS network stack and switch to offline mode when the network is unavailable. The controlOfflineMode action lets you override this automatic behaviour and drive the offline state explicitly from within your action chains.
When offline mode is active, the app serves all data from its local cache (configured in App Settings → Offline → Cache Strategy), queues any mutations in the outbox, and blocks new data source requests. When you disable offline mode, the app reconnects and — if flushQueue is true — syncs the outbox before resuming normal operation.
Note: Offline capability must be enabled first. The app's offline support (service worker, cache strategy, outbox) is configured in App Settings → Offline. The controlOfflineMode action has no effect if offline mode is not enabled in settings — it will log a warning in the debugger panel.
Parameters
| Parameter | Type | Required | Default | Description |
| operation | "enable" | "disable" | "toggle" | Required (required) | — | enable forces the app into offline mode regardless of actual network availability. disable clears the manual override and returns control to automatic detection. toggle switches between the two states. |
| flushQueue | boolean | Optional (optional) | true | When true and operation is "disable", all queued outbox mutations are sent to the server in order before the app resumes live operation. Set to false to re-enable online mode without syncing (the outbox is preserved for the next sync cycle). |
| showBanner | boolean | Optional (optional) | true | When true, the app's built-in offline indicator banner is shown/hidden as the offline state changes. Set to false to manage the offline UI yourself with conditional visibility on custom blocks. |
App Offline State Variable
The global app variable appState.isOffline reflects the current offline mode state (both automatic and manually forced). Bind visibility conditions, disabled states, or informational banners to this variable:
Binding examples
// Hide a submit button when offline Visible: {{ !appState.isOffline }} // Show a custom offline banner Visible: {{ appState.isOffline }} // Show outbox queue count Text: {{ appState.offlineQueueCount }} pending changes
Use Cases
Testing Offline Behaviour
During development, wire a toggle button to controlOfflineMode with operation: "toggle" to simulate going offline without disconnecting your laptop's Wi-Fi. This is faster than using browser DevTools network throttling and works identically on mobile previews.
Forced Offline for Metered Connections
In field apps (construction sites, warehouses), users on metered data plans may want to pre-load data over Wi-Fi and then work offline for hours. Provide an explicit "Go Offline" button that calls enable and an "Sync Now" button that calls disable with flushQueue: true. This gives users full control over data consumption.
Low-Data Scenarios
Detect a slow network (e.g. via a ping data source that measures response time) and proactively enable offline mode to prevent failed API calls and poor UX. Use a banner to inform the user that they are in low-data mode.
Examples
Toggle offline mode from a settings button
{ "actionType": "controlOfflineMode", "payload": { "operation": "toggle", "showBanner": true } }
Sync and go online — "Sync Now" button pattern
{ "actionType": "controlOfflineMode", "payload": { "operation": "disable", "flushQueue": true, "showBanner": true } }
Force offline when network quality degrades
// Triggered by a data source that measures API ping latency // Run condition: {{ ds_pingCheck.response.latencyMs > 5000 }} { "actionType": "controlOfflineMode", "payload": { "operation": "enable", "showBanner": true } }
Warning: Manual override persists across page navigations. A manually enabled offline mode stays active until you explicitly call disable. If the user closes and reopens the app, the state resets to automatic detection. Store the manual override preference in a persistent variable or user profile if you need it to survive app restarts.