npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sovereignbase/offline-kv-store

v1.0.2

Published

Namespace-scoped key-value storage on top of IndexedDB with explicit error codes.

Readme

npm version CI codecov license

offline-kv-store

Small namespace-scoped key-value storage on top of IndexedDB. It is designed for local-first browser data where each namespace maps to its own object store and operations fail with explicit error codes instead of silent fallthrough.

Compatibility

  • Runtimes: modern browsers and runtimes that expose global indexedDB
  • Module format: ESM and CJS.
  • Required globals / APIs: indexedDB, DOMException.
  • TypeScript: bundled types.

Goals

  • Simple put / get / has / delete / clear API per namespace.
  • Explicit error surfaces with stable code strings.
  • Dynamic namespace creation backed by IndexedDB object stores.
  • Small public surface: KVStore, resolveDB, and destroyDB.

Installation

npm install @sovereignbase/offline-kv-store
# or
pnpm add @sovereignbase/offline-kv-store
# or
yarn add @sovereignbase/offline-kv-store
# or
bun add @sovereignbase/offline-kv-store
# or
deno add jsr:@sovereignbase/offline-kv-store
# or
vlt install jsr:@sovereignbase/offline-kv-store

Usage

import { KVStore } from '@sovereignbase/offline-kv-store'

const settings = new KVStore<string>('settings')

await settings.put('theme', 'dark')

const theme = await settings.get('theme')
console.log(theme) // "dark"

console.log(await settings.has('theme')) // true

await settings.delete('theme')
await settings.clear()

Namespaces

Each KVStore instance is bound to one namespace:

import { KVStore } from '@sovereignbase/offline-kv-store'

const profiles = new KVStore<{
  name: string
  email: string
  verified: boolean
}>('profiles')
const drafts = new KVStore<{
  title: string
  body: string
  updatedAt: string
}>('drafts')

await profiles.put('alice', {
  name: 'Alice',
  email: '[email protected]',
  verified: true,
})
await drafts.put('welcome', {
  title: 'Hello',
  body: 'Draft content goes here.',
  updatedAt: new Date().toISOString(),
})

Direct database lifecycle

import { destroyDB, resolveDB } from '@sovereignbase/offline-kv-store'

const db = await resolveDB()
console.log(db.name) // "offline-kv-store"

await destroyDB()

Runtime Behavior

Browsers / IndexedDB runtimes

Namespaces are created on demand. The first operation for a new namespace may trigger an IndexedDB version upgrade to create the backing object store.

Validation and errors

Validation failures and runtime failures reject with errors named KVStoreError. The error object includes a code property such as:

  • NAME_WAS_INVALID
  • DATABASE_OPEN_FAILED
  • DATABASE_OPEN_BLOCKED
  • DATABASE_DELETION_FAILED
  • DATABASE_DELETION_BLOCKED
  • INDEXED_DB_TRANSACTION_FAILED
  • INDEXED_DB_TRANSACTION_ABORTED

Tests

  • Suite: unit + integration in Node, browser E2E in Playwright.
  • Browser matrix: Chromium, Firefox, WebKit, mobile Chrome, mobile Safari.
  • Coverage: c8 at 100% statements / branches / functions / lines for the Node test pass.
  • Command: npm run test

Benchmarks

How it was run: npm run bench
Environment: Node v22.14.0 on win32 x64 using the repository benchmark harness.

| Operation | Workload | Time | Throughput | | ------------------------------- | -------- | --------- | -------------- | | namespace provision + first put | 200 ops | 97.92 ms | 2,042.43 ops/s | | put | 2000 ops | 293.87 ms | 6,805.64 ops/s | | get | 2000 ops | 516.10 ms | 3,875.20 ops/s | | has | 2000 ops | 565.26 ms | 3,538.22 ops/s | | delete | 2000 ops | 823.03 ms | 2,430.05 ops/s | | clear | 1 op | 3.58 ms | 279.30 ops/s |

Results vary by machine and runtime. These numbers come from the included Node benchmark harness, not from an in-browser benchmark.

License

Apache-2.0