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

@hamzasaleemorg/convex-kv

v1.0.2

Published

Hierarchical Key-Value store for Convex

Readme

Convex KV Component

npm version npm downloads License

A hierarchical, ordered key-value store for Convex. Replace relational boilerplate with a simple get/set API, featuring automatic TTL and recursive prefix deletion.

Installation

npm install @hamzasaleemorg/convex-kv
// convex/convex.config.ts
import { defineApp } from "convex/server";
import convexKv from "@hamzasaleemorg/convex-kv/convex.config.js";

const app = defineApp();
app.use(convexKv);

export default app;

Quick Start: Expiring Invite Links 🚀

Manage one-time magic links or invite codes without cluttering your main schema or writing cleanup logic.

// convex/invites.ts
import { kvClientFactory } from "@hamzasaleemorg/convex-kv";
import { components } from "./_generated/api";
import { mutation } from "./_generated/server";
import { v } from "convex/values";

const kv = kvClientFactory(components.convexKv);
const invites = kv.use<{ email: string; role: string }>(["invites"]);

export const createInvite = mutation({
  args: { email: v.string(), role: v.string() },
  handler: async (ctx, args) => {
    const inviteCode = Math.random().toString(36).substring(7);
    
    // Store invite that automatically EXPIRES in 48 hours
    await invites.set(ctx, [inviteCode], { 
      email: args.email, 
      role: args.role 
    }, { ttl: 48 * 60 * 60 * 1000 });
    
    return inviteCode;
  },
});

export const acceptInvite = mutation({
  args: { code: v.string() },
  handler: async (ctx, args) => {
    // If the link is older than 48hrs, .get() returns null automatically
    const invite = await invites.get(ctx, [args.code]);
    if (!invite) throw new Error("Invite invalid or expired");
    
    // ... create membership logic ...

    await invites.delete(ctx, [args.code]);
  },
});

🛠️ Why use this?

  1. Zero Schema Maintenance: Store any JSON-serializable data instantly. No new tables, no indexes to wait for.
  2. Organized Hierarchy: Use array keys like ["org", orgId, "settings"] to naturally isolate data.
  3. Automatic TTL: Set a ttl (ms) on any key and it disappear from queries as soon as it expires.
  4. Ordered Scans: Keys are stored lexicographically. Scan through millions of keys by prefix instantly.
  5. Batched Deletes: Clear an entire "folder" of data with deleteAll(["prefix"]). It automatically handles large datasets in the background.

API Reference

Initializing the Client

You can use the global client or scope it to a specific recursive namespace:

const kv = kvClientFactory(components.convexKv);

// Everything sent through 'users' will stay in that folder
const users = kv.use<{ email: string }>(["users"]);

Core Operations

| Method | Description | | :--- | :--- | | get(key) | Returns value or null if missing/expired. | | set(key, val, options?) | Stores value. Options: ttl (ms), expiresAt, metadata. | | has(key) | Fast boolean check for existence (returns false if expired). | | delete(key) | Removes a specific key. |

Hierarchical & Range Operations

| Method | Description | | :--- | :--- | | list(prefix, options?) | Paginated scan within a namespace. | | getAll(prefix) | Returns all entries under a prefix (max 1000). | | deleteAll(prefix) | Recursive Delete. Safely clears an entire prefix tree in the background. |


Development & Testing

npm install
npm run dev   # Starts the KV Explorer & Build Watcher
npm test      # Runs full suite (Unit + Component Integration)

License

Apache-2.0