Self-deploy the backend
Run the Sync & Mesh backend in your own Cloudflare account with the
mezair-cloud CLI. It uses the same Worker source as Mezair-hosted, from
mezair-app/cloud/backend. The CLI lives in mezair-cloud.
Self-hosting has no Mezair subscription fee; Cloudflare bills you for the
resources you use. The lifecycle commands below accept --json for automation.
Set it up with your agent
Copy this prompt into your coding agent. It will guide the setup in your own Cloudflare account.
Help me self-host Mezair Sync & Mesh in my Cloudflare account.
Follow https://mezair.dev/docs/sync/self-deploy and the current CLI help. Use my existing Mezair checkout, or clone https://github.com/anthonyhumphreys/mezair into a new directory. Work in the relevant project directories.
Ask which Cloudflare account, Worker name and backend URL I want to use. Show the resources to be created and any hosting costs before deploying. Use self-hosted mode and the documented deployment workflow. Keep generated configuration reproducible and enter secrets through the supported secret-input mechanism without printing their values.
Check that the deployed backend is reachable and passes the Sync compatibility checks. Finish with the backend URL, a discovery file, and the steps to connect Mezair Desktop and enroll my first device. Explain how to connect a second device and remove this deployment later.mesh plan
mezair-cloud mesh plan --backend <path> --name <worker> \
[--stage production] [--env <name>] [--account-id <id>] \
[--base-url <url> | --subdomain <sub>] [--bucket <name>] \
[--oidc-issuer <url> --oidc-client-id <id>] [--first-deploy] [--json]plan computes the deployment and writes a generated wrangler.mesh.jsonc.
Change the CLI options rather than editing this file; the next plan replaces it.
The generated configuration includes:
- Durable Object bindings for the coordination objects the backend uses;
- cumulative SQLite migrations. A deployable config always carries its
full migration history, so
--first-deployrecords intent only and does not change what gets emitted; - the R2 artifact bucket for sealed artifact bytes.
--base-url and --subdomain are the addressing choice (a real URL or a
workers.dev subdomain); --oidc-issuer/--oidc-client-id pin the identity
the deployment advertises. Point --backend at the worker source:
mezair-app/cloud/backend in the monorepo.
Provision, migrate, apply, and secrets
plan only computes configuration. For a real non-production deployment, run
the lifecycle commands with the same target options on every invocation:
mezair-cloud mesh provision --backend <path> --mode self-hosted --name <worker> \
--account-id <id> --base-url <url> --bucket <name> --json
mezair-cloud mesh migrate --backend <path> --mode self-hosted --name <worker> \
--account-id <id> --base-url <url> --bucket <name> --json
mezair-cloud mesh apply --backend <path> --mode self-hosted --name <worker> \
--account-id <id> --base-url <url> --bucket <name> \
--stage staging --test-deployment --json
mezair-cloud mesh secrets --backend <path> --mode self-hosted --name <worker> \
--account-id <id> --base-url <url> --bucket <name> \
--from-file <secret-json> --jsonprovision creates or reuses the selected R2 bucket. migrate applies any
declared database migrations (self-hosted mode has no hosted billing D1).
apply deploys through Wrangler; it does not install secrets or claim that a
live backend is healthy. Install secrets after the Worker exists because the
Worker must exist before Wrangler can attach them. --dry-run performs local
checks without deploying. Production apply/remove requires --evidence <ref>; initial staging checks use --test-deployment.
mesh connection
mezair-cloud mesh connection --name <worker> --base-url <url> \
[--stage production] [--out <path>] [--allow-insecure] [--json]Writes the discovery file the desktop app's Sync & Mesh settings consume
That is the descriptor a "Your Cloudflare" or "Compatible backend" mode reads to
learn endpoints, protocols, auth issuer, and negotiated limits.
--allow-insecure exists for non-TLS development URLs; do not point a real
backend at it.
mesh remove
mezair-cloud mesh remove --backend <path> --name <worker> \
[--evidence <ref>] [--json]remove regenerates its own plan before deleting. It never targets
whatever config happened to be generated last, so teardown deletes the worker
you named, not a stale one.
Check your backend
After deployment, run the compatibility checks against your backend:
pnpm conformance -- --url <backend> --admin-token <token>Wiring the desktop app
mesh plan+mesh apply→ worker live, secrets provisioned, admin ready.mesh connection→ discovery file.- Desktop: Settings → Sync & Mesh → Your Cloudflare (or Compatible backend) → paste the base URL or load the discovery file → sign in and choose Sync for each workspace whose portable configuration you want to share.
Pinning stores the backend association only. Sync stays off until you sign in and choose Sync for a workspace. See Connection modes for the full model.
This deploys the account backend; it does not provision host routes. Supported upgraded clients use an encrypted live host session only when a route is enabled and reachable. Managed HTTPS routes use a provider proxy, are off by default, and require separate operator setup.
Self-host account page
A self-hosted Worker serves an operator page at /account. It is deliberately
not the hosted WorkOS account area: hosted deployments return no account page
there and keep account management on the website. On a self-hosted Worker,
enter the deployment admin token and an account id at /account to issue the
first device enrollment code. The token is entered and used in the browser tab
only. After the first device is enrolled, use Mezair Desktop's normal device
management and in-app pairing for additional devices. The page's inspection
control is an operator convenience, not a replacement for device auth.
Related
- CLI reference for flags, exit codes and JSON output.
- Sync & Mesh overview for connection modes and what syncs.