Turso is a distributed database built on libSQL (a fork of SQLite). The @libsql/client driver speaks HTTP and WebSocket, so the same DaloyJS app works on Node, Bun, Deno, and Cloudflare Workers.
One client, two connection modes
@libsql/clientcreateClient(...)HTTP and WebSocket
node / bunEmbedded replicaurl: file:local.db + syncUrl · local reads, writes to primary
The same createClient() driver serves both modes. Use an embedded replica on Node or Bun for ultra-low-latency local reads, and the remote HTTP client on Cloudflare Workers.
1. Provision
Create a database via the Turso CLI or dashboard, then grab the URL and auth token. Set them as TURSO_DATABASE_URL and TURSO_AUTH_TOKEN.
Add the declare module block to the same module that creates the client, not to a separate .d.ts file. Declaration files are exempt from type-checking when skipLibCheck is on (the scaffolded default), so a broken import inside a .d.ts fails silently and state.db quietly degrades to any.
ts
// src/db/turso.ts (same module as the plugin above)declare module "@daloyjs/core" { interface AppState { db: Client; }}