Skip to content

JavaScript SDK

Official client library for Node.js and browsers.

Terminal window
npm install @kv-storage/client
import { KVClient } from '@kv-storage/client';
const kv = new KVClient('YOUR_API_KEY');

Store a value.

await kv.put('myapp', 'user:123', { name: 'John' });

Retrieve a value.

const { value } = await kv.get('myapp', 'user:123');

Delete a value.

await kv.delete('myapp', 'user:123');

List keys with optional prefix.

const { keys } = await kv.list('myapp');
const { keys } = await kv.list('myapp', 'user:');

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 User
try {
await kv.get('myapp', 'nonexistent');
} catch (error) {
console.error(error.message);
}