Skip to content
UniKVS
English
Esc
↑↓navigate↵open⌘Jpreview
On this page

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 AbortSignal and passing of runtime variables.
  • Storages for both Node.js and browsers.

Quickstart

npm install unikvs @unikvs/compression @unikvs/fs.node
pnpm add unikvs @unikvs/compression @unikvs/fs.node
yarn add unikvs @unikvs/compression @unikvs/fs.node
bun add unikvs @unikvs/compression @unikvs/fs.node
nub add unikvs @unikvs/compression @unikvs/fs.node
aube add unikvs @unikvs/compression @unikvs/fs.node
import { 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

Packages

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.

Was this page helpful?