Skip to main content

General SDK

Database & Sync

Connection

Battery

Performance

Bluetooth

Security

Versioning

Quickstart

MongoDB Connector

General SDK

There are 3 ways for Ditto enabled apps to sync without connectivity:WiFi Access Point (LAN) WiFi Access Point, also known as LAN, is when devices discover and sync with each other over the same local network. Typically, this means you have a wireless access point where your devices are all connected to. Even if the internet or modem fails, devices will still be able to synchronize. This is completely cross-platform.WiFi Aware and Apple Wireless Direct Link (AWDL) Apple and Android devices are able to create peer to peer WiFi connections with each other. However these are not cross platform. Meaning that, Apple devices (iOS, iPadOS, and macOS) are only able to connect to other Apple devices via Apple Wireless Direct Link. Android devices are able to make P2P WiFi Aware connections with each other.Bluetooth Low Energy iOS and Android devices are able to connect with each other over a standard Bluetooth Low Energy (BLE) connection. Ditto supports both Bluetooth 4.x and 5.x protocols seamlessly. Devices that support the faster L2CAP mode of BLE sync at about 20 kB/second; older devices use the slower GATT mode (see How fast is the sync?). If a Bluetooth 5.x device needs to connect with a Bluetooth 4.x device, the devices will connect over a Bluetooth 4.x protocol.
Ditto offers a large range of devices and OS support for each of our SDKs. For specific support see the compatibility map for your given language Directory of Compatibility Maps
At the heart of Ditto is a realtime database that takes in JSON-like data structures. That means that even if a device with Ditto is completely disconnected from other devices, it will still have the data stored locally. That means even in a completely offline environment, users will still be able to edit, read, and observe data. When devices reconnect, they will exchange relevant information that was edited when they were offline. You can think of this as a similar behavior to Google Docs or Google Sheets.

Database & Sync

Yes. Ditto relays documents through the devices in between, but a device can relay only the documents it stores, that is, the documents that its own subscriptions match. The subscriptions of the devices in between must cover the data that the devices behind them need, but the queries do not have to be identical. See Multi-hop Sync.
Yes. Apps that use the same Database ID and compatible authentication settings sync with each other. On one device, each app needs its own persistence directory, because a persistence directory can be open in only one process at a time.
Yes. The Ditto SDK provides sync.start() and sync.stop() methods that will enable and disable network sync.
iOS offers best-effort background sync provided Bluetooth LE is enabled and the Bluetooth central and peripheral background modes are enabled. On Android, declare Ditto’s foreground service to keep syncing in the background; without it, sync stops while the app is in the background (see Declaring a Foreground Service in the Kotlin install guide).
See above about background mode.
This will depend on the type of data, query complexity and the performance required. As a rule of thumb, a device running the Ditto SDK such as a mobile device is designed to handle up to 2GB of key-value data and tens of thousands of documents in a collection.Data synced using the file attachments API is stored outside the main database and does not contribute towards the 2GB. Even very large attachments are supported and the limits will depend mostly on the storage and network bandwidth available on your device.
The data will be merged when the data from one device reaches the other device.
Yes. You can perform multiple updates, across multiple documents in multiple collections, inside a single write transaction. Read more

Connection

Ditto provides a Presence Viewer UI for Swift, Android, and .NET (see Using Ditto Developer Tools) that can be launched within your app to show all active connections to other devices. This information can also be accessed programmatically using the ditto.presence SDK function.
If a device is disconnected, this will be reflected through the ditto.presence.observe() callback.
You can specify which transport types to enable, e.g. Bluetooth only, WiFi only, or everything. Ditto will use its own algorithms to decide which devices to connect to and which modes to use. Ditto always prioritizes the fastest connection that is available, and will optimistically upgrade to a faster connection whenever possible.
If, separate to Ditto, you know the complete list of devices in your team then you can use the ditto.presence functionality provided by the SDK to keep track of which devices are online. Therefore you’ll be able to determine which devices are offline.If you don’t maintain a separate list of devices in your team then the best you can currently do is to keep track of all devices that Ditto sees, again by making use of the ditto.presence API. You can then use this list of all known devices to keep track of which of those are online/offline at any given moment.
Yes.You can use both direct communication between devices running the Ditto SDK (device-to-device) and communication by way of a server (Ditto Server) that connects and transmits data between devices running the Ditto SDK (device-to-server-to-device).This dual approach provides flexibility — your app remains efficient in any network environment and you control when and what routes through a central server. However, web browsers do not support peer-to-peer transports. That means a web app will only be able to connect to Ditto Server over WebSockets.
No. The browser-based Web SDK connects to Ditto Server exclusively over WebSockets. It does not support peer-to-peer transports such as Bluetooth LE, LAN, or P2P Wi-Fi. This means a web app cannot participate in local device-to-device mesh sync when the network is down. This is because the web browser blocks web applications’ access to peer-to-peer transports such as BLE.If your use case requires offline or LAN-only sync without Ditto Server, use a native SDK (iOS, Android, Linux, Windows, or macOS) instead.
No. Android Wi-Fi Aware is only capable of syncing with other Android devices. Apple devices running iOS and macOS are capable of syncing over Apple Wireless Direct Link. These two transports are not compatible with each other. However, other transports like Bluetooth Low Energy and Access Points will be able to sync with each other just fine.

Security

Use Development mode (formerly Online Playground) for development and testing, Online with Authentication for production apps that connect to Ditto Server, and Offline Shared Key for closed deployments without Ditto Server. See Authentication and Authorization.
By default, Ditto does not encrypt its local database. In the Swift and Kotlin SDKs, you can encrypt the local database, including attachments, by passing a 32-byte key in DittoConfig.encryptionKey (see Encryption at Rest). Other SDKs do not support encryption at rest yet.Both iOS and Android provide OS-level disk encryption (iOS Data Protection and Android file-based encryption, respectively) that can protect data stored on the device. This protection is only active when a screen lock (passcode, PIN, or biometric) is configured. It does not necessarily protect the data while the device is locked: by default, iOS keeps app data accessible after the user has unlocked the device for the first time after a restart (see Setting Protection Entitlement), and Android makes an app’s storage available once the user has first entered their credentials after boot.On unmanaged devices — such as those used by end users who download your app from a public App Store — you cannot guarantee that device-level encryption is enabled, since your app has no control over the user’s device settings.For applications handling regulated or sensitive data (for example, PHI under HIPAA, payment data under PCI, or similar requirements), relying solely on OS-level encryption may not satisfy compliance controls. Your app cannot programmatically verify or enforce whether the end user’s device has encryption enabled.
If you are building for a regulated environment, consider encrypting sensitive field values at the application level before writing them to Ditto. You can also contact the Ditto team for guidance on architecture patterns that address compliance requirements.
For more on Ditto’s authentication and security model, see Cloud Authentication.
The JavaScript (Web) SDK stores all data in memory (RAM) only for the duration of the browser session. No data is written to localStorage, sessionStorage, or IndexedDB.When the browser tab or window is closed, all local Ditto data is released. The Web SDK does not leave persistent data artifacts in the browser, which can be a relevant consideration for applications handling sensitive data.
Ditto will only connect to devices that use the same database ID and matching credentials: the same shared key, or certificates from the same Ditto Server. To decide connection by connection, you can use a connection request handler to accept or reject them. See Limiting Connections.
Communication is encrypted using TLS 1.3 and peer identities are verified using certificates, either issued by Ditto Server or derived from your shared key. In development mode, all devices share the same certificate, so the certificate does not identify a device. TLS 1.3 is the same state-of-the-art technology used in web browsers. It applies to every communication mode from Bluetooth to WiFi.
With Online with Authentication, your authentication webhook returns a set of permissions for each device. These permissions decide which collections and documents a device may read and write. See Data Authorization. With development mode or a shared key, every device has the same access.Within the data that a device has access to, the device receives only the documents that match its subscriptions, so register subscriptions only for the data that you wish to be synced. Store observers read the local database and do not change what syncs.
Ditto provides multiple production security modes that robustly protect against eavesdropping. You can either use a shared secret key, or device-specific keys with a central authority.Ditto also has a development mode, in which any device that knows the database ID and the Playground token can connect. This is not secure, and provided for ease of development.
Ditto certificates are standard X.509 certificates. With Online with Authentication, each device has a keypair and the certificate grants that device a unique ID and the permissions that your authentication webhook returned for which collections and documents it may read and write. With a shared key, each device issues a self-signed certificate from the shared key. Organizations with strict on-premises requirements may operate their own certificate authority (CA). Certificates can also be generated and distributed automatically from Ditto Server. For more information about certificate deployments please speak to us.

Bluetooth

Bluetooth Classic is an older mode used for accessories like headphones. It requires a manual pairing procedure between devices. Ditto does not use Bluetooth Classic.Bluetooth Low Energy (BLE) is a more recent mode of Bluetooth that consumes less power and removes the need for user interaction when connecting to another device. Ditto’s Bluetooth synchronization employs this mode exclusively.
No. Ditto uses exclusively Bluetooth Low Energy, which does not require pairing.
Ditto will take advantage of features in newer versions of BLE when they are supported by both devices. These features are optional, and Ditto sync will work with even the earliest BLE hardware adapters.
Approximately 100 metres (tested in the open with modern Apple hardware). Newer hardware usually performs better.
Yes, Bluetooth Low Energy sync can operate at the same time as other Bluetooth devices such as headphones.

Battery

The SDK is designed to be as power-efficient as possible. We strive to keep CPU and network usage to a minimum.
Ditto should not be affected in most circumstances, although background sync on iOS may become less reliable.

Performance

Ditto can be used in Airplane Mode. If Bluetooth or WiFi is manually toggled on after selecting Airplane Mode, then Ditto will be able to sync using those modes.
  • WiFi: the full speed of your connection, typically 1 gigabyte of data in times as low as 8 seconds.
  • WiFi Aware: similar to WiFi speeds
  • Bluetooth LE: typically 20 kB/second (however, if you’re using a device that is below Android 10, then Ditto will use BLE GATT which is only 3 to 6 kB/second.)
  • Ditto Server: 40k transactions per second (25k write txns + 15k reads)
A Ditto document has a soft limit of 256 KiB, above which Ditto logs a warning, and a hard limit of 5 MiB, above which Ditto rejects the write. See Document Size Limits. Large files can be stored as attachments, which are not subject to these limits. For the size of the whole database, see the 2GB rule of thumb in Is there a limit to the amount of data? Like other databases, Ditto will use as much storage as the data you insert into the device, so controlling the size of Ditto in your app is up to you.
There is no fixed limit, but each collection has a cost: it adds storage, makes creating further collections slower, and cannot be removed (see DELETE). Use a small, fixed set of collections and put variable parts, such as a user or a date, in document fields instead of creating a collection for each. The collection name is not stored with each document, so its length does not affect the size of your documents.
Your results may vary depending on the size of your documents and the number of them you are querying. Contact us for help with implementing performance testing for your use case.

Versioning & Upgrading

We aim to have a version of the iOS SDKs that is compatible with latest iOS version before the iOS version has been made available to the public. We will likely publish preview releases or release candidates of the SDKs during the iOS beta period, if necessary (see SDK Versioning Lifecycle).