convex-kv

Store hierarchical key-value data in Convex with namespaced paths, supporting nested keys and efficient queries for configuration and metadata.

Installation

npm install @hamzasaleemorg/convex-kv

About convex-kv

Hierarchical Key-Value store for Convex

Benefits

Use cases

how to store app configuration in Convex

@hamzasaleemorg/convex-kv enables storing configuration with hierarchical keys like 'app/theme/colors/primary'. You can organize settings by namespace and query specific branches of your configuration tree without creating multiple tables.

Convex key value store with nested keys

This component provides a hierarchical key-value interface over Convex tables, supporting nested paths like 'users/123/preferences/notifications'. You can set and get values at any level of the hierarchy while maintaining Convex's real-time reactivity.

store metadata in Convex database

@hamzasaleemorg/convex-kv allows storing metadata with structured keys like 'resources/images/upload-settings'. You can organize metadata by category and retrieve specific subsets without complex queries or table joins.

Frequently asked questions

How does @hamzasaleemorg/convex-kv handle nested key structures?

@hamzasaleemorg/convex-kv uses path-like keys with forward slashes to create hierarchical structures. You can store values at paths like 'app/settings/theme/mode' and query all keys under a specific namespace like 'app/settings'. The component handles the path parsing and storage internally while providing a simple get/set API.

Can I query all keys under a specific namespace?

Yes, @hamzasaleemorg/convex-kv supports namespace queries where you can retrieve all key-value pairs under a specific path prefix. For example, querying 'app/settings' would return all configuration keys that start with that path, enabling you to fetch entire configuration sections at once.

Does this component work with Convex real-time updates?

@hamzasaleemorg/convex-kv maintains full compatibility with Convex's real-time reactivity. When you update a key-value pair, any queries or subscriptions watching that key or its parent namespace will automatically update, providing live updates to your application state and configuration changes.

What's the difference between this and regular Convex tables?

@hamzasaleemorg/convex-kv provides a key-value abstraction over Convex tables specifically designed for hierarchical data. Instead of designing schemas for configuration or metadata tables, you can use familiar key-value operations with nested paths. It's ideal for settings, feature flags, and metadata that doesn't fit well into structured table schemas.

Links