This directory contains Ditto's quickstart app for Electron desktop applications. The Ditto Node SDK runs in Electron's main process, providing full peer-to-peer sync. The UI is a React + TypeScript app in the renderer process, communicating with Ditto over Electron's IPC.
- Node.js v22.12 or later (matches the floor of the bundled Electron runtime)
- macOS (Apple Silicon)
- Linux (x64, arm64)
- Windows (x64)
Electron applications run code in two processes that share no memory: a Node.js main process (full OS access) and a Chromium renderer process (a sandboxed browser window). Because the Ditto Node SDK is a native addon, it must run in main. This quickstart wires it up like this:
main process preload (context bridge) renderer (React)
βββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββ
Ditto.open(config) contextBridge.exposeInMainWorld window.ditto.*
auth.login(...) ('ditto', api) window.ditto.onTasksUpdated(cb)
sync.start() ipcRenderer.invoke / .on
registerSubscription
registerObserver βββββΊ webContents.send('tasks:updated', tasks) βββββΊ setTasks(tasks)
The renderer never imports @dittolive/ditto; it only calls window.ditto.* methods exposed by the preload script via contextBridge. Context isolation is enabled and Node integration is disabled in the renderer β the standard secure Electron defaults.
This quickstart enables LAN sync (TCP + mDNS + multicast) and disables Bluetooth LE and AWDL. BLE and AWDL on macOS require entitlements that only signed app bundles get; a plain npm run dev Electron process can't use them. LAN P2P provides peer-to-peer sync between devices on the same network, and the DITTO_SERVER_URL provides sync to Ditto's Big Peer.
Ditto's local store is persisted at app.getPath('userData'), which resolves to:
- macOS:
~/Library/Application Support/Ditto Tasks/ - Linux:
~/.config/Ditto Tasks/ - Windows:
%APPDATA%/Ditto Tasks/
Tasks survive restarts because of this. To reset, quit the app and delete that directory.
To get started, you'll first need to create an app in the Ditto Portal with the "Development" authentication type. You'll need your Database ID, Development Token, and Server URL.
From the repo root, copy the .env.sample file to .env, and fill in the fields:
cp .env.sample .env
The .env file should look like this (with your fields filled in):
DITTO_DATABASE_ID=""
DITTO_DEVELOPMENT_TOKEN=""
DITTO_SERVER_URL=""Then run the app:
cd electron
npm install
npm run dev
If npm run dev fails with Error: Electron uninstall, the Electron binary was not downloaded during npm install (this can happen if scripts were skipped or a network error occurred) on Windows. Fix it by running the install script manually:
node node_modules/electron/install.js
Then re-run npm run dev.