UniKVS
Overview and documentation guide for UniKVS, a modular KVS client built with TypeScript.
What is UniKVS
UniKVS is a modular and portable KVS client built with TypeScript. It combines Transformers that transparently convert data with Storages that write to multiple backends, using a builder pattern.
Its main features are:
- Transparent encoding and decoding via Transformers.
- Parallel writes to multiple Storages.
- Per-key Value types that control available operations at the type level.
- Runtime validation of input and output values with Valibot schemas.
- Support for both single values and streams.
- Cancellation via
AbortSignaland passing of runtime variables. - Storages for both Node.js and browsers.
Quickstart
npm install unikvs @unikvs/compression @unikvs/fs.nodepnpm add unikvs @unikvs/compression @unikvs/fs.nodeyarn add unikvs @unikvs/compression @unikvs/fs.nodebun add unikvs @unikvs/compression @unikvs/fs.nodenub add unikvs @unikvs/compression @unikvs/fs.nodeaube add unikvs @unikvs/compression @unikvs/fs.nodeimport { Compression } from "@unikvs/compression";
import { NodeFs } from "@unikvs/fs.node";
import { UniKvs, type Value } from "unikvs";
const kvs = UniKvs.config<{
foo: Value<Uint8Array<ArrayBuffer>>;
}>()
.appendTransformer(new Compression("gzip"))
.appendStorage(new NodeFs(".tmp"))
.create();
await kvs.open();
await kvs.set("foo", Uint8Array.from([0, 1, 2]));
const bytes = await kvs.get("foo");
await kvs.close();
The example above transparently compresses the bytes for key foo with gzip and saves them under .tmp/.
How to read the docs
Getting started
Try the shortest path from installation to basic operations.
Concepts
Understand pipelines, Value types, and variables.
Guides
See usage patterns for specific goals.
Storage comparison
Guidance for choosing a storage backend.
Packages
UniKVS
The config builder and KVS client itself.
@unikvs/core
Shared types and error foundation for all packages.
@unikvs/utils
Shared helpers for plugin authors.
@unikvs/compression
Compresses and decompresses with gzip, deflate, and deflate-raw.
@unikvs/checksum
Validates MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
@unikvs/json
Serializes values to JSON, or to JSON Lines in streams.
@unikvs/superjson
Serializes values with SuperJSON, preserving Date, Map, Set, BigInt, and undefined.
@unikvs/cbor
Serializes values to CBOR, or to a CBOR sequence in streams.
@unikvs/memory
Stores arbitrary data in memory.
@unikvs/fs.node
Stores data in the Node.js local filesystem.
@unikvs/fs.bun
Stores data in the Bun local filesystem.
@unikvs/redis.bun
Stores data in Redis with Bun’s Redis client.
@unikvs/s3.node
Stores data in S3-compatible object storage.
@unikvs/s3.bun
Stores data in S3-compatible object storage from Bun.
@unikvs/opfs
Stores data in the browser OPFS.
@unikvs/indexeddb
Stores data in the browser IndexedDB.
@unikvs/writeonly
Turns an existing storage into write-only storage.
@unikvs/debug
Logs the operations and debug information of data read and written.
@unikvs/passthrough
Passes data through without transforming it.
Environments
| Package | Node.js | Bun | Browser |
|---|---|---|---|
unikvs |
Supported. | Supported. | Supported. |
@unikvs/core |
Supported. | Supported. | Supported. |
@unikvs/utils |
Supported. | Supported. | Supported. |
@unikvs/compression |
Supported. | Supported. | Supported. |
@unikvs/checksum |
Supported. | Supported. | Supported. |
@unikvs/json |
Supported. | Supported. | Supported. |
@unikvs/superjson |
Supported. | Supported. | Supported. |
@unikvs/cbor |
Supported. | Supported. | Supported. |
@unikvs/memory |
Supported. | Supported. | Supported. |
@unikvs/fs.node |
Supported. | Not supported. | Not supported. |
@unikvs/fs.bun |
Not supported. | Supported. | Not supported. |
@unikvs/redis.bun |
Not supported. | Supported. | Not supported. |
@unikvs/s3.node |
Supported. | Not supported. | Not supported. |
@unikvs/s3.bun |
Not supported. | Supported. | Not supported. |
@unikvs/opfs |
Not supported. | Not supported. | Supported. |
@unikvs/indexeddb |
Not supported. | Not supported. | Supported. |
@unikvs/writeonly |
Supported. | Supported. | Supported. |
@unikvs/debug |
Supported. | Supported. | Supported. |
@unikvs/passthrough |
Supported. | Supported. | Supported. |