The Local-First, AI-Native Database for the Web. Featuring WASM SQLite, Vector Embeddings, and MCP support.
npm install @affectively/dashThe Local-First, AI-Native Database for the Modern Web.
Dash 2.0 isn't just a database; it's a complete data engine for building high-performance, intelligent web applications. It brings server-grade power to the client, enabling apps that feel instant, work offline, and understand your users.
If you built your local-first app a year or two ago, you probably had to persist data by serializing the whole DB to IndexedDB or localStorage. It was slow and blocked the main thread.
The new standard is SQLite over OPFS (Origin Private File System).
It gives the browser direct, performant handle access to a virtual file system optimized for random access.
You can run full ACID transactions on a multi-gigabyte SQLite file in the browser with near-native desktop performance, without ever blocking the UI thread (thanks to SharedArrayBuffer).
Combined with Zero-Copy (BYOB) readers and UCAN-based Zero-Trust Auth, Dash isn't just a database—it's a local-first operating system.
- Stateful Serverless: Powered by Cloudflare Durable Objects and Native SQLite.
- Zero-Copy IO (BYOB): "Bring Your Own Buffer" readers for max throughput.
- ACID Compliant: Full transactional integrity in the browser.
- Vector Search: Built-in vector embeddings and search.
- 3-Tier Acceleration:
1. WebNN: NPU acceleration (Apple Neural Engine, etc.)
2. WebGPU: High-performance GPU parallelization.
3. WASM/CPU: Universal fallback.
- Semantic Queries: Find data by _meaning_ at native speeds.
- Hybrid Transport:
- WebSocket: Supports Cloudflare Durable Object Hibernation ($0 idle cost).
- WebTransport: UDP-like high-frequency streams (perfect for cursors/games).
- Zero-Trust Auth (UCANs): Decentralized authorization via User Controlled Authorization Networks.
- Lens: Bidirectional schema migrations for infinite backward compatibility.
- Direct Buffers: Zero-copy bindings allow piping data directly into 3D engines like Three.js.
- Spatial Indexing: R-Tree support for massive 3D visualizations.
- Drop-In Replacement: Use Firebase imports, Dash implementation. All your code works unchanged.
- All 4 Modules: Firestore, Realtime Database, Auth, Cloud Storage.
- 100% Compatible: 150+ Firebase APIs with identical behavior.
- 10-50x Faster: Local-first queries at 0ms latency vs 15-25ms network round-trips.
- Unique Advantages: Vector search, E2E encryption, offline-first, AI/ML built-in.
``typescript
// Before (Firebase)
import { collection, getDocs } from 'firebase/firestore';
// After (Dash - your code unchanged!)
import { collection, getDocs } from '@affectively/dash';
// Same code, 10-50x faster, fully offline ✅
const docs = await getDocs(collection(db, 'users'));
`
Learn more: Firebase Compatibility Guide
`bash`
npm install @affectively/dash
Dash provides a familiar SQL interface with Promise-based execution.
`typescript
import { dash } from "@affectively/dash";
await dash.ready();
// Standard SQL execution
await dash.execute("CREATE TABLE IF NOT EXISTS todos (id TEXT, text TEXT)");
await dash.execute("INSERT INTO todos VALUES (?, ?)", ["1", "Buy milk"]);
const rows = await dash.execute("SELECT * FROM todos");
console.log(rows);
`
Store content with automatic vector embeddings and query by meaning.
`typescript
// Add an item (automatically generates and stores vector embedding)
await dash.addWithEmbedding("1", "Buy almond milk and eggs");
// Search by meaning - "breakfast ingredients" matches "eggs" and "milk"!
const results = await dash.search("breakfast ingredients");
// Result: [{ id: '1', content: '...', score: 0.85 }]
`
Filter items by 3D bounds for high-performance spatial lookups.
`typescript`
// Query a 3D bounding box
const items = await dash.spatialQuery({
minX: 0,
maxX: 100,
minY: 0,
maxY: 100,
minZ: 0,
maxZ: 100,
});
Bind query results directly to your application state.
`typescript
import { liveQuery, effect } from "@affectively/dash";
// This signal automatically updates whenever the 'todos' table changes
const todos = liveQuery("SELECT * FROM todos");
effect(() => {
console.log("Current Todos:", todos.value);
});
`
Enable collaboration and data safety with a single line.
`typescript
import { SyncConnection, backup } from "@affectively/dash";
// 1. Peer-to-Peer Sync (WebTransport - Recommended)
// Requires a WebTransport Relay Server (Star Topology)
const connection = new SyncConnection({
type: "webtransport",
roomName: "my-room",
url: "https://relay.dash.dev/sync",
doc,
});
// OR: Peer-to-Peer Sync (WebRTC - Legacy)
// Mesh Topology (Client-to-Client)
const p2p = new SyncConnection({
type: "webrtc",
roomName: "my-room",
doc,
});
// 2. Encrypted Cloud Backup
await backup("my-room", doc, mySecretKey, cloudAdapter);
`
Dash uses @sqlite.org/sqlite-wasm with the OPFS backend to ensure main-thread responsiveness. Large data operations occur in the WASM heap, avoiding the serialization overhead of IndexedDB.
Vector operations utilize sqlite-vec (WASM) for high-performance similarity search.
For a deep dive into our "Stateful Serverless" Client-Relay topology using Cloudflare Durable Objects, read the Sync Architecture Guide.
`bashBuild the project
npm run build
MIT