New KV Features: Add, Update, Remove, and List Improvements
We've updated the Puter.js Key-Value store with new APIs that let you build more sophisticated applications. Instead of overwriting entire values for every change, you can now perform partial updates, append to arrays, remove specific fields, and paginate through large key sets.
Let's look at each new feature.
puter.kv.add()
The add() function lets you append values to an existing key. This is useful when you want to add items to an array without fetching and re-saving the entire value.
// Set up initial data
await puter.kv.set('profile', { tags: ['alpha'] });
// Add more tags without overwriting the existing ones
const updated = await puter.kv.add('profile', { 'tags': ['beta', 'gamma'] });
console.log(updated); // { tags: ['alpha', 'beta', 'gamma'] }
The path notation ('tags') lets you target nested fields. No more read-modify-write cycles just to append to a list. View the puter.kv.add() documentation
puter.kv.update()
The update() function lets you modify specific fields within a stored object without overwriting the rest. This is perfect for partial updates to complex data structures.
// Set up initial data
await puter.kv.set('profile', {
name: 'Puter',
stats: { score: 10, level: 1 }
});
// Update only the fields you need
const updated = await puter.kv.update('profile', {
'stats.score': 11,
'name': 'Puter Smith'
});
console.log(updated);
// { name: 'Puter Smith', stats: { score: 11, level: 1 } }
Dot notation paths let you reach into nested objects. View the puter.kv.update() documentation
puter.kv.remove()
The remove() function deletes specific fields from a stored object by path. Use this when you need to remove properties without affecting the rest of the value.
// Set up initial data
await puter.kv.set('profile', {
name: 'Puter',
stats: { score: 10, level: 2 },
temporary: 'delete me'
});
// Remove specific fields
const updated = await puter.kv.remove('profile', 'stats.score', 'temporary');
console.log(updated);
// { name: 'Puter', stats: { level: 2 } }
You can remove multiple paths in a single call. View the puter.kv.remove() documentation
puter.kv.list()
The list() function now supports pagination through limit and cursor options. This makes it easy to work with large key sets without loading everything at once.
// Get first page with a limit
const firstPage = await puter.kv.list({ limit: 5 });
console.log(firstPage.items);
// Get next page using the cursor
if (firstPage.cursor) {
const secondPage = await puter.kv.list({ cursor: firstPage.cursor });
console.log(secondPage.items);
}
Pass limit to control how many keys to return per page, and use cursor from the previous response to fetch the next page. View the puter.kv.list() documentation
Get Started
These new APIs are available now—no API keys, no setup. Start building more sophisticated stateful applications with Puter.js today.
Related:
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now