Deno KV is a built-in key-value database that comes with the Deno runtime. No setup, no dependencies, no external services — just import and use.
Why Deno KV is Revolutionary
A developer needed a database for a small API. Setting up PostgreSQL meant Docker, migrations, connection pooling, and environment variables. With Deno KV, they added a database with zero setup — it's built right into the runtime.
Key Features:
- Zero Setup — Built into Deno runtime, no installation needed
- ACID Transactions — Full transactional support
- Global Replication — Distributed across Deno Deploy edge network
- Watch API — Real-time change notifications
- Free Tier — Generous limits on Deno Deploy
Quick Start
const kv = await Deno.openKv()
// Set a value
await kv.set(["users", "alice"], { name: "Alice", email: "alice@example.com" })
// Get a value
const result = await kv.get(["users", "alice"])
console.log(result.value) // { name: "Alice", email: "alice@example.com" }
Atomic Transactions
const kv = await Deno.openKv()
// Transfer money atomically
await kv.atomic()
.check({ key: ["accounts", "alice"], versionstamp: aliceEntry.versionstamp })
.set(["accounts", "alice"], { balance: aliceBalance - 100 })
.set(["accounts", "bob"], { balance: bobBalance + 100 })
.commit()
List with Prefix
// List all users
const iter = kv.list({ prefix: ["users"] })
for await (const entry of iter) {
console.log(entry.key, entry.value)
}
Why Choose Deno KV
- Zero infrastructure — no databases to manage
- Built-in — no npm install, no config
- Edge-native — globally distributed on Deno Deploy
Check out Deno KV docs to get started.
Need data storage solutions? Check out my Apify actors or email spinov001@gmail.com for custom web scraping.
Top comments (0)