Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 2 min read How-to mediumAdept

Use Turso as your Unkey cache store

Turso can serve as the backing store for Unkey's `@unkey/cache` middleware library through its `LibSQLStore` adapter. Setup takes four steps: install `@unkey/cache` and `@libsql/client`, create a `cache` table with key, value, freshUntil and staleUntil columns, pass a libSQL client to `LibSQLStore`, and register it in a cache namespace with fresh (60s) and stale (15m) windows. Pointing the client at an Embedded Replica (`file:local.db` with a `syncUrl`) keeps the cache next to the app to cut read latency.

Related posts

  • Bringing SQLite to Vercel Functions with Turso

    Turso mediumAdept

    Turso'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.

  • Toasty now fully supports Turso

    Turso mediumAdept

    Toasty, the async Rust ORM from Tokio's creator, now supports Turso in three modes behind one API: local files with optional concurrent writes (transactions automatically wrapped in BEGIN CONCURRENT), a serverless remote mode over HTTP with URL and auth token, and local-first sync with explicit pull/push calls. Only the driver constructor changes between modes, so the same models and queries run unchanged. For remote use, toasty::batch() combines independent statements into one round trip and returns typed tuple results, avoiding a network round trip per transaction statement.

  • Introducing Databases Anywhere with Turso Sync

    Turso mediumAdept

    Turso 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).

  • Introducing Offline Writes for Turso

    Turso easyNovice

    Turso 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 mediumAdept

    Turso 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.

The quest for software engineering knowledge.

Look:
Layout: