sync package provides a client-side runtime for building offline-first applications. It combines reactive state primitives (Signals, Computed values, Effects) with synchronized collections that stay in sync with a server.
What is Offline-First?
In a traditional web application, the server is the source of truth. When youβre offline, the app doesnβt work.- App works without internet
- Instant UI updates (no loading spinners)
- Better user experience on slow connections
- Resilience to network failures
What the Sync Package Provides
Reactive Primitives
These provide fine-grained reactivity similar to SolidJS or Vueβs Composition API.
Synchronized State
The Sync Protocol
The client and server communicate using a simple protocol:- Push: Client sends queued mutations to server
- Pull: Client requests changes since last sync point (cursor)
- Snapshot: Client requests full state (initial load or resync)
Reactive Primitives
Signal
A Signal holds a value and notifies subscribers when it changes:Computed
A Computed value derives from other signals and updates automatically:Effect
An Effect runs a function whenever its dependencies change:Collections and Entities
Collections manage groups of entities that sync with a server:Quick Example
Hereβs a complete example showing the sync system:Architecture
When to Use Sync
Use sync when:- Building offline-capable applications
- You need instant UI updates without loading states
- Multiple clients need to see synchronized data
- You want fine-grained reactivity in Go
- Building server-side only applications
- You donβt need offline support
- Simple request/response patterns are sufficient
Whatβs Next?
- Quick Start - Build your first synced app
- Client - Client configuration and lifecycle
- Reactive - Deep dive into Signal, Computed, Effect
- Collections - Working with synchronized data
- Integration - Combining sync with live for real-time updates