'Hello World' Sync
Once you've set up your environment, try on Ditto and perform your first peer‑to‑peer sync.
Intended to get you oriented, this article provides a streamlined process for integrating sync functionality within your app.
If you prefer building and exploring through a task app, chat app, and so on, see Example Projects Overview and
Integrate the Ditto SDK in your codebase, set up authentication, and then start syncing offline:
From the top-most scope of your app's codebase, add the following to set up authentication and start syncing offline.
Replace YOUR_APP_ID and YOUR_PLAYGROUND_TOKEN with your access credentials available from the portal.
Register a new sync subscription in your app; for example, to establish a subscription to sync updates to documents to the cars collection with a field of color set to the value blue, as follows:
Sync subscriptions also support argument injection using the :argument syntax in Ditto Query Language (DQL) so you can dynamically customize your queries at runtime.
For more information about DQL — Ditto's dedicated query language — see Ditto Query Language.
Retrieve active sync subscriptions by calling the subscriptions API method on the ditto.sync namespace:
To check if a sync subscription is canceled, call the isCancelled field on the subscription object: