JavaScript SDK
Official client library for Node.js and browsers.
Installation
Section titled “Installation”npm install @kv-storage/clientimport { KVClient } from '@kv-storage/client';
const kv = new KVClient('YOUR_API_KEY');Methods
Section titled “Methods”put(namespace, key, value)
Section titled “put(namespace, key, value)”Store a value.
await kv.put('myapp', 'user:123', { name: 'John' });get(namespace, key)
Section titled “get(namespace, key)”Retrieve a value.
const { value } = await kv.get('myapp', 'user:123');delete(namespace, key)
Section titled “delete(namespace, key)”Delete a value.
await kv.delete('myapp', 'user:123');list(namespace, prefix?)
Section titled “list(namespace, prefix?)”List keys with optional prefix.
const { keys } = await kv.list('myapp');const { keys } = await kv.list('myapp', 'user:');TypeScript Support
Section titled “TypeScript Support”Full TypeScript support with type inference:
interface User { name: string; email: string;}
const { value } = await kv.get<User>('myapp', 'user:123');// value is typed as UserError Handling
Section titled “Error Handling”try { await kv.get('myapp', 'nonexistent');} catch (error) { console.error(error.message);}