Key-Value Store
Keep a setting without making a collection. Your app's title, a feature switch, the prompts your page sends a
model, the last time a job ran: each is one value, not a table of records. $kv stores it under a name and gives it
back:
const settings = $kv.get("storytime/settings") ?? { title: "Story Time", minutes: 10 }
var settings Settings
found, err := kvv1.Get(app, "storytime/settings", &settings)
There's no collection to create and no migration to write. Values live in PocketBase's own _params table, beside its
settings, so they ride along in every backup. It's built into pocketone and on by default.
The examples show each thing in TypeScript, as Pages page code or pb_hooks, and in
Go. The Go examples use the contract's helpers (kvv1 is pocketone.dev/ext/contracts/kv/v1).
Read and write values
A value is anything JSON can hold: an object, a list, a string, a number, true or false.
$kv.set("storytime/settings", { title: "Story Time", minutes: 10, voices: ["alloy"] })
const s = $kv.get("storytime/settings") // { title: "Story Time", minutes: 10, voices: ["alloy"] }
const none = $kv.get("storytime/nothing") // null: no value under that name
$kv.delete("storytime/settings") // no error when there was nothing to delete
err := kvv1.Set(app, "storytime/settings", Settings{Title: "Story Time", Minutes: 10})
var s Settings
found, err := kvv1.Get(app, "storytime/settings", &s) // found is false, and s untouched, when there's no value
err = kvv1.Delete(app, "storytime/settings")
Every call is quick and local (one read or write of your app's database), so $kv has no Async forms. set
replaces the whole value: to change one field, read the value, change it and set it again.
Defaults until someone changes them
A common shape: ship defaults with your app, and store a value only once someone changes something.
const defaults = { title: "Story Time", minutes: 10 }
// read: the stored settings over the defaults
const settings = { ...defaults, ...($kv.get("storytime/settings") ?? {}) }
// save: only what the form sent
$kv.set("storytime/settings", { ...settings, minutes: Number(body.minutes) })
Merging over the defaults means a field you add in a later version gets its default on apps that saved settings before it existed.
List values
Names can share a prefix, and list returns every value whose name starts with it, sorted by name:
$kv.list("storytime/")
// [{ name: "storytime/settings", value: {...}, created: "2026-11-22T10:00:00Z", updated: "..." }, ...]
entries, err := kvv1.List(app, "storytime/") // each has Name, Value (JSON), Created, Updated
$kv.list() with no prefix returns every value in the store.
Names
A name is 1 to 128 characters: letters, digits and _ - . : /, starting with a letter or digit. Start yours with a
prefix of your own, such as your app's or extension's name (storytime/settings), so they never meet another
extension's. A name that breaks these rules throws (in Go, returns kvv1.ErrInvalidName).
Names starting with _ are private to Go code on the app. Extensions keep their secrets there (LLM's provider keys
are _llm/settings): $kv, the API and agents can't read, change or list them.
A value is at most 1 MiB of JSON. For more than that, or for many similar things you want to filter, sort or let users own, use a collection.
From outside the app
Superusers can read and change values from the API, the pocketone command and agents, for example to fix a setting
on a live app:
curl -H "Authorization: $TOKEN" "https://app.example.com/api/_c/kv/v1?prefix=storytime/" # list
curl -H "Authorization: $TOKEN" "https://app.example.com/api/_c/kv/v1/get?name=storytime/settings" # one value
curl -H "Authorization: $TOKEN" -d '{"name":"storytime/settings","value":{"minutes":15}}' \
https://app.example.com/api/_c/kv/v1/set
curl -H "Authorization: $TOKEN" -d '{"name":"storytime/settings"}' https://app.example.com/api/_c/kv/v1/delete
$TOKEN is a superuser's token, or an API token with the kv:read scope (list, get) or
kv (all four). From your project folder, pocketone remote kv does the same on the project's remote:
pocketone remote kv list --prefix storytime/
pocketone remote kv get --name storytime/settings
pocketone remote kv set --name storytime/settings --value '{"minutes":15}' # --value @settings.json reads a file
pocketone remote kv delete --name storytime/settings
Agents get them as MCP tools (kv_list, kv_get, kv_set, kv_delete). Users and guests can't reach the store:
your page code decides what, if anything, they see.
Good to know
- Where values live: the value named
storytime/settingsis the_paramsrow with idkv:storytime/settings. Thekv:prefix keeps your names apart from PocketBase's own rows (itssettings) and from rows other extensions keep there. Read and write through$kvor the helpers, never the table. - Transactions: the Go helpers take any
core.App, so insideapp.RunInTransactionpass the transaction's app and the write is part of it.$kv, like$app, writes through the main app. - Turning it off:
kv: {enabled: false}inpocketone.yamlremoves$kvand the API. The Go helpers keep working, since they need nothing but the database.
Next
- Key-Value Store reference: the extension's page.
- kv/v1: the contract, for extension authors.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.