UniKVS
Documentation for UniKVS, a modular KVS client for TypeScript. Choose tutorials, how-to guides, explanations, or references depending on your goal.
UniKVS is a modular, portable KVS client for TypeScript. It combines middleware that transparently transforms data with storages that write to multiple backends, assembled through a builder.
How to Read
These docs follow the four Diátaxis categories. Pick the entry point that matches your current goal.
Tutorials
First-time users build something hands-on to grasp the big picture.
How-to Guides
Follow task-oriented steps to solve a problem.
Explanation
Understand how it works and the design behind it.
Reference
Look up backend comparisons and operation specs.
Quickstart
Start with the minimal in-memory setup. It takes about 5 minutes.
import { Memory } from "@unikvs/memory";
import * as unikvs from "unikvs";
const kvs = new unikvs.Builder<{
greeting: unikvs.PlainValue<string>;
}>()
.persist(new Memory())
.build();
await kvs.open();
await kvs.set("greeting", "hello");
const value = await kvs.get("greeting");
console.log(value); // "hello"
await kvs.close();
See Your First UniKVS for the full walkthrough.
Key Features
- Transparent encoding and decoding via middleware.
- Parallel writes to multiple storages.
- Per-key value types that restrict available operations at the type level.
- Runtime validation of input/output values with Valibot schemas.
- Support for both single values and streams.
- Cancellation via
AbortSignaland per-operation runtime variables. - Storages for both Node.js and browsers.
Packages
Each package is documented in the package reference. Representative packages:
UniKVS
The config builder and KVS client itself.
@unikvs/memory
Stores arbitrary data in memory.
@unikvs/compression
Compresses and decompresses with gzip, deflate, and deflate-raw.
@unikvs/json
Converts values to JSON, and streams to JSON Lines.
@unikvs/fs.node
Stores data on the local filesystem in Node.js.
@unikvs/opfs
Stores data in the browser OPFS.