Sync Workers
pendingby OJII3
Sync your vault with a self-hosted Cloudflare Workers backend.
Obsidian Sync Workers
A self-contained Obsidian sync system powered entirely by Cloudflare - a monorepo containing a Workers + D1 + R2 server and an Obsidian plugin.
日本語ドキュメント / Japanese Documentation:
Overview
This is an Obsidian sync server that runs entirely on Cloudflare services. No external databases like CouchDB are required, and it can be operated within Cloudflare's free tier.
This project consists of two packages:
- Server (
packages/server) - Sync server using Cloudflare Workers and D1 database - Plugin (
packages/plugin) - Obsidian plugin (client-side)
Key Features
- Document CRUD operations
- Revision management and conflict detection
- Change feed (incremental sync)
- Soft delete
- Multi-vault support
- Auto sync / manual sync
- Conflict resolution UI (auto merge + manual selection)
- Attachment sync (R2)
Architecture
Obsidian Plugin (Client)
↓
Cloudflare Workers (Elysia Framework)
↓
D1 Database (SQLite) + R2 (Attachments)
Setup
Prerequisites
- Bun (latest version recommended)
- Cloudflare account (for server deployment)
- Wrangler CLI (can be run via
bunx wrangler)
1. Clone the Repository and Install Dependencies
git clone https://github.com/OJII3/obsidian-sync-workers.git
cd obsidian-sync-workers
bun install
Server Setup
0. Generate and Configure API Key (Required)
openssl rand -hex 32
Configure the generated key as follows:
- Local development: Add
API_KEY=your-generated-keytopackages/server/.dev.vars - Production: Set via
wrangler secret put API_KEYcommand
Use the same API key for both the server and the plugin.
1. Create D1 Database
cd packages/server
bunx wrangler d1 create obsidian-sync
Set the output database_id in wrangler.jsonc under d1_databases[0].database_id.
2. Apply Database Schema
# Production
bun run db:init
# Local development
bun run db:local
3. Create R2 Bucket (for Attachment Sync)
bunx wrangler r2 bucket create obsidian-attachments
The R2 binding is already configured in wrangler.jsonc.
4. Start Local Development Server
# From packages/server directory
bun run dev
# Or from root directory
bun run dev:server
The server will start at http://localhost:8787.
5. Deploy
Method 1: GitHub Actions (Recommended)
Deploy by forking the repository and using GitHub Actions.
-
Fork this repository
-
Prepare in Cloudflare Dashboard:
- Create D1 database (
obsidian-sync) - Create R2 bucket (
obsidian-attachments) - Create API token (requires Workers edit permission)
- Create D1 database (
-
In your forked repository, go to Settings → Secrets and variables → Actions and set:
CLOUDFLARE_API_TOKEN: Cloudflare API tokenCLOUDFLARE_ACCOUNT_ID: Cloudflare account ID
-
Update the
database_idinpackages/server/wrangler.jsoncwith the actual value and commit -
Go to the Actions tab and manually run the "Deploy Server" workflow (Run workflow)
-
After deployment, set the API key via Cloudflare Dashboard or CLI:
bunx wrangler secret put API_KEY
Method 2: Manual Deploy
# Set API key for production
cd packages/server
bunx wrangler secret put API_KEY
# Enter API key at the prompt
# Deploy
bun run deploy
# Or from root directory
bun run build:server
Plugin Setup
Development Mode
# From packages/plugin directory
bun run dev
# Or from root directory
bun run dev:plugin
Build
# From packages/plugin directory
bun run build
# Or from root directory
bun run build:plugin
Install to Obsidian
-
Copy the entire
packages/plugindirectory to Obsidian's plugin folder:# Linux/Mac cp -r packages/plugin /path/to/your/vault/.obsidian/plugins/obsidian-sync-workers # Windows xcopy packages\plugin C:\path\to\your\vault\.obsidian\plugins\obsidian-sync-workers /E /I -
Restart Obsidian
-
Go to Settings → Community plugins → Enable Obsidian Sync Workers
Plugin Configuration
- Open Settings → Obsidian Sync Workers
- Set Server URL (e.g.,
https://your-worker.workers.devorhttp://localhost:8787) - Enter the same API key as the server
- Set Vault ID (default:
default) - Enable Auto sync (optional)
- Set Sync interval (choose from 5 seconds to 60 minutes)
- Enable Sync attachments (to sync binary files like images)
- Click Test to test server connection
- Click Sync now to perform manual sync
Usage
Manual Sync
- Click the sync button in the ribbon
- Run "Sync now" from the command palette (Ctrl/Cmd+P)
Auto Sync
Enable Auto sync in settings to automatically sync at the specified interval.
Commands
Sync now- Execute sync immediatelyToggle auto sync- Toggle auto sync on/off
Troubleshooting
Cannot Connect to Server
- Verify the server is running
- Check if Server URL is correct
- Verify API key is configured (saved in plugin)
- If CORS error, check CORS settings on server side
Sync Not Working
- Test connection with Test button
- Check browser console logs
- Check server logs
Plugin Not Showing
- Verify plugin is correctly copied to plugin folder
- Verify
main.jsis built - Restart Obsidian
Specifications and Development Notes
For specifications and internal implementation details, see CLAUDE.md. For development notes on each package, refer to:
CLAUDE.mdpackages/server/CLAUDE.mdpackages/plugin/CLAUDE.md
License
MIT
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.