How Sample Vault syncs gigabyte-scale databases from cloud to local with Turso
Sample Vault, an AI sample browser for music producers, gives each premium user a dedicated Turso database. Processing (spectral analysis, ML classification, AI tagging) runs in the cloud and syncs down to a full local embedded replica, so libraries of 100K to 1.2M+ audio files are queryable offline. Supabase failed on connectivity and upload speed, PGLite used too much RAM and had no sync layer, and Electric SQL and PowerSync were too expensive and synced in the wrong direction. Sync runs on launch, every 5 minutes, and on demand, and database-per-user tenancy avoids noisy neighbours without any custom sync code.
Related posts
- Introducing Databases Anywhere with Turso Sync
Turso mediumAdeptTurso Sync lets local SQLite-compatible Turso databases, in Node or in the browser via WASM, sync with Turso Cloud through push, pull and sync-aware checkpoint methods layered on the standard database API. Local changes are pushed as row-level logical mutations with Last-Push-Wins conflict resolution, and a transform hook lets developers rewrite mutations for custom merge logic. Remote changes are pulled as physical pages, so replicas converge byte-for-byte on the cloud source of truth, which rules out peer-to-peer sync. The launch also adds per-table, per-operation token permissions and external JWKS/OIDC auth (Clerk and Auth0 in beta).
- 2 million databases and counting: the architecture behind Sauna's AI teammate
Turso easyNoviceSauna, a proactive AI work assistant, gives every session, agent and connected inbox or calendar its own Turso database, creating about 90,000 databases a day and over 2 million in total. The team moved from Cloudflare Durable Objects to Containers with Litestream, which proved slow and expensive, and switched to Turso once per-database pricing was removed. Turso Sync keeps each database as a local file with two-way sync: on a conflicting pull it atomically rolls back to the last synced state, applies remote changes and replays local writes. The database-per-connection model simplifies isolation between users and lets storage outlive compute when changing hosting providers.
- Bringing SQLite to Vercel Functions with Turso
Turso mediumAdeptTurso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency. On cold start the driver fetches the first 128 KiB of the SQLite file, then pulls further 128 KiB segments on demand into the ephemeral /tmp directory, so cold-start cost scales with the working set rather than total database size. The experimental @tursodatabase/vercel-experimental package also auto-provisions databases by name for database-per-tenant or per-agent-session patterns. It offers an optional local-write batching mode that trades consistency for lower write latency, and uses a waitUntil() safety net that pushes pending changes if close() is forgotten.
- Introducing Offline Writes for Turso
Turso easyNoviceTurso is opening a private beta for Offline Writes, letting applications write to local embedded SQLite replicas while online or offline and sync those changes to the cloud later. Local writes land in the SQLite write-ahead log, and sync pushes or pulls WAL frames to and from the remote database. Conflict handling stays simple and assumes mostly serialized writers: the first push wins, and the others pick a strategy such as fail-on-conflict, discard-local, rebase-local or a custom resolver. The pitch is that pairing this with a database-per-user design makes local-first apps simpler, because the whole database syncs rather than a selected subset.
- Building Local-First Apps: The Complete Guide to Offline-First Database Sync
Turso mediumAdeptTurso Sync brings local-first behaviour to SQLite-based apps. Local changes are captured via change data capture and pushed as logical row-level mutations, while remote changes are pulled as physical pages so replicas converge byte-for-byte. Turso's benchmarks report up to 312x faster syncs and roughly 18x less traffic than the older Embedded Replicas approach. The guide covers TypeScript setup with background push/pull loops, Last-Push-Wins conflict resolution and a transform hook for custom merges such as turning sets into increments, scoped auth tokens and JWKS, sync-aware WAL checkpointing, and experimental partial sync. It also notes that there is no CRDT or peer-to-peer support, which makes the approach a poor fit for real-time collaborative document editing.