Dedicated WebSocket endpoint for cr-sqlite CRDT synchronization between multiple devices for the same user.
This API enables offline-first messaging by synchronizing local SQLite databases across devices using cr-sqlite's CRDT-based merge algorithm.
crsql_changes virtual table/api/v1/syncauth_token cookiesync_request to get changes from other devicessync_push/sync_ack messages for incremental updatesLocal development server
Staging server (TLS required)
Production server (TLS required)
Dedicated WebSocket channel for cr-sqlite synchronization.
Authentication: JWT token must be present in auth_token cookie.
Connection is rejected with close code 4001 if token is invalid or expired.
Routing: Messages are broadcast to all other connections belonging
to the same user (identified by JWT sub claim).
Request changes from other devices
Sent when a device comes online or reconnects to request any changes
that occurred while it was offline. Other devices respond with sync_response.
Available only on servers:
Accepts the following message:
{
"type": "sync_request",
"version": 1,
"siteId": "YWJjZGVmZ2hpamtsbW5vcA==",
"timestamp": 1701388800000,
"payload": {
"sinceVersion": 0
}
}
Dedicated WebSocket channel for cr-sqlite synchronization.
Authentication: JWT token must be present in auth_token cookie.
Connection is rejected with close code 4001 if token is invalid or expired.
Routing: Messages are broadcast to all other connections belonging
to the same user (identified by JWT sub claim).
Receive sync response with changes
Response to a sync_request containing changes since the requested version.
Available only on servers:
Accepts the following message:
Response containing requested changes
{
"type": "sync_response",
"version": 1,
"siteId": "cXdlcnR5dWlvcGFzZGZnaA==",
"timestamp": 1701388801000,
"payload": {
"changes": [
{
"table": "messages",
"pk": "bXNnLTEyMzQ1",
"cid": "content",
"val": "Hello!",
"col_version": 1,
"db_version": 42,
"site_id": "cXdlcnR5dWlvcGFzZGZnaA==",
"cl": 1,
"seq": 0
}
],
"currentVersion": 42
}
}
Dedicated WebSocket channel for cr-sqlite synchronization.
Authentication: JWT token must be present in auth_token cookie.
Connection is rejected with close code 4001 if token is invalid or expired.
Routing: Messages are broadcast to all other connections belonging
to the same user (identified by JWT sub claim).
Push local changes to other devices
Sent after local database modifications to propagate changes to other devices.
Recipients should apply changes and respond with sync_ack.
Available only on servers:
Accepts the following message:
{
"type": "sync_push",
"version": 1,
"siteId": "YWJjZGVmZ2hpamtsbW5vcA==",
"timestamp": 1701388802000,
"payload": {
"changes": [
{
"table": "messages",
"pk": "bXNnLTY3ODkw",
"cid": "content",
"val": "New message",
"col_version": 1,
"db_version": 50,
"site_id": "YWJjZGVmZ2hpamtsbW5vcA==",
"cl": 1,
"seq": 0
}
],
"baseVersion": 49
}
}
Dedicated WebSocket channel for cr-sqlite synchronization.
Authentication: JWT token must be present in auth_token cookie.
Connection is rejected with close code 4001 if token is invalid or expired.
Routing: Messages are broadcast to all other connections belonging
to the same user (identified by JWT sub claim).
Receive acknowledgment of applied changes
Confirmation that pushed changes were received and applied (or rejected).
Available only on servers:
Accepts the following message:
{
"type": "sync_ack",
"version": 1,
"siteId": "cXdlcnR5dWlvcGFzZGZnaA==",
"timestamp": 1701388803000,
"payload": {
"receivedVersion": 50,
"appliedCount": 1
}
}
Request changes from other devices
Response containing requested changes
Acknowledgment of received changes
Request changes from other devices since a specific version
Response containing changes since requested version
Push local changes to other devices
Acknowledgment of received and applied changes
Single cr-sqlite CRDT change record from the crsql_changes virtual table.
Represents a column-level change that can be merged across devices.
Error encountered during sync operation
Reason for WebSocket connection close