Skip to main content
The sync client is a Go runtime for building offline-first applications. It manages local state, queues mutations, and synchronizes with the server. This guide covers client configuration and usage. The client runtime is designed for Go applications (mobile, desktop, CLI). For browser applications, you’ll typically implement a JavaScript client that uses the same sync protocol.

Creating a Client

Configuration Options

BaseURL (Required)

The sync server endpoint:

Scope (Required)

The data partition to sync:

HTTP

Custom HTTP client for requests:

Persistence

Save state between app restarts:

Callbacks

React to sync events:

Intervals

Control sync timing:

Client Lifecycle

Starting the Client

Start does:
  1. Loads persisted state (if configured)
  2. Performs initial sync (snapshot or pull)
  3. Starts background push/pull loops

Stopping the Client

Stop does:
  1. Cancels background goroutines
  2. Saves state (if persistence configured)

Manual Sync

Force an immediate sync:

Mutations

Queueing Mutations

Use Mutate to queue changes:

Mutation Flow

Status

Online Status

Current Cursor

Live Integration

For real-time updates, integrate with the live package:
This triggers an immediate pull instead of waiting for the next poll interval.

Complete Example

Error Handling

Sync Errors

Start Errors

Double Start

Best Practices

1. Always Handle Errors

2. Use Persistence

For a good offline experience, persist state:

3. Start Early

Start the client as early as possible:

4. Handle Offline Gracefully

5. Integrate with Live

For real-time updates: