Type-safe with Schema Validation
Runtime validation with Zod, Valibot, ArkType, and other Standard Schema libraries. Ensure data integrity at every operation.
Runtime schema validation with pluggable storage drivers for Node.js

Install Valkeyrie in your project:
npm install valkeyriepnpm add valkeyrieyarn add valkeyrieCreate a type-safe key-value store with schema validation:
import { Valkeyrie } from 'valkeyrie'
import { z } from 'zod'
// Define your schema with Zod (or Valibot, ArkType, etc.)
const userSchema = z.object({
name: z.string(),
email: z.string().email(),
age: z.number().min(0)
})
// Register the schema and open the database
const db = await Valkeyrie
.withSchema(['users', '*'], userSchema)
.open('./my-data.db')
// Set a value - automatically validated!
await db.set(['users', 'alice'], {
name: 'Alice',
email: 'alice@example.com',
age: 30
})
// Get the value - fully typed!
const user = await db.get(['users', 'alice'])
// user.value type: { name: string, email: string, age: number } | null
// List all users with prefix
for await (const entry of db.list({ prefix: ['users'] })) {
console.log('User:', entry.value)
}
// Watch for changes
for await (const entries of db.watch([['users', 'alice']])) {
console.log('User updated:', entries[0].value)
}Valkeyrie brings the best of both worlds: the simplicity of key-value stores and the safety of runtime schema validation.
Never trust input data again. Valkeyrie validates every value against your schema at runtime, catching bugs before they become problems.
Define your schema once, get TypeScript types everywhere. No more maintaining parallel type definitions.
Modify multiple keys in a single atomic operation with automatic conflict resolution. No more race conditions.
Choose the serializer that fits your needs:
MIT © Ducktors