Browse documentation

Client transport

Lime Sync uses the real @rocicorp/zero client API and local cache. The browser transport that connects it to Lime Sync is currently provided by orez-lite/client, so the client and server halves of the wire protocol ship together.

Install the transport before constructing Zero:

import { Zero } from '@rocicorp/zero'
import { createZeroClientTransport } from 'orez-lite/client'

const server = 'https://sync.example.com'
const transport = createZeroClientTransport({
  pullIntervalMs: 5_000,
  wake: true,
})

transport.install(server)

const zero = new Zero({
  server,
  userID,
  auth,
  schema,
  mutators,
})

createZeroClientTransport() returns a reusable plugin. Calling install() again for the same server returns the existing transport when its options are identical. Conflicting options throw instead of installing a second WebSocket shim.

Application endpoints

Use pullOrigin and pushOrigin when the authoritative HTTP endpoints live at a different base URL from the Lime Sync host:

const transport = createZeroClientTransport({
  pullOrigin: 'https://app.example.com/api/zero',
  pushOrigin: 'https://app.example.com/api/zero',
})

transport.install('https://sync.example.com')

The transport sends bearer auth from Zero’s connection to both endpoints. appID and shardNum configure the routing parameters on push requests.

Browser boundary

orez-lite/client is a browser-only leaf export. It contains the HTTP transport and payload codec interface, and does not import the Orez Node runner, PostgreSQL, server, or host code. Import server integration separately from orez-lite/native, orez-lite/browser, or orez-lite/cloudflare.