Adds KV-backed field types and whole collections that keep fast-changing or short-lived data in Upstash Redis, Vercel KV or Cloudflare Workers KV. Values come back in normal find calls across the Local API, REST and GraphQL with access control, where and sort support. Registered through kvPlugin and works on Postgres, SQLite and MongoDB with Payload 3.94+ or 4 beta.
Redis / KV-backed fields and collections for Payload CMS (v3 and v4): counters, feeds, TTL data — queryable, access-controlled and populated alongside your SQL data
Installation
npm i payload-kv0
Stars
0
Forks
0
Open Issues
Today
Last Updated
1.4k
Weekly Downloads
v0.1.8
npm Version
991.2 KB
Unpacked Size
0
Dependencies
00 since Nov 29
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
Trends appear after 7 days of data. Collecting since Dec 4 — 3 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1479317750-root)<a href="https://payloaddirectory.dev/plugins/1479317750-root"><img src="https://payloaddirectory.dev/badge/1479317750-root.svg" alt="Payload Directory"></a>README
Redis-backed counters, feeds and expiring data for Payload CMS.
Keep fast-changing and short-lived data in Upstash, Vercel KV or Cloudflare KV,
and keep using it like any other Payload data.
// a post lives in Postgres; its views, likes and comments live in Redis
const post = await payload.findByID({ collection: 'posts', id })
// → { title, views: 1203, likes: 87, likedByMe: true, comments: [...the latest 10] }
await getKV(payload).incr({ collection: 'posts', id, field: 'views' }) // no database write
const popular = await payload.find({
collection: 'posts',
sort: '-views',
where: { likes: { greater_than: 10 } },
})
Views, likes, comment feeds, presence, carts and reservations change constantly or expire. Writing every change to your database means row locks, version churn, updatedAt noise and slow writes. payload-kv keeps that data in Redis, and your Payload app doesn't notice:
find, through the Local API, REST and GraphQL, with access control, depth, select, where and sort.fetch, with no SDK, on Node, the edge and serverless.npm install payload-kv
import { kvCounter, kvList, kvPlugin, kvSet, kvSetHas } from 'payload-kv'
export default buildConfig({
collections: [
{
slug: 'posts',
fields: [
{ name: 'title', type: 'text' },
kvCounter({ name: 'views', index: true }),
kvSet({ name: 'likes', index: true, writeAccess: ({ req }) => Boolean(req.user) }),
kvSetHas({ name: 'likedByMe', set: 'likes' }),
kvList({ name: 'comments', fields: [{ name: 'body', type: 'textarea' }] }),
],
},
],
plugins: [kvPlugin()],
})
Create a Redis database on Upstash (or add Upstash for Redis from the Vercel Marketplace) and set its REST credentials:
UPSTASH_REDIS_REST_URL=https://...upstash.io
UPSTASH_REDIS_REST_TOKEN=...
kvPlugin() picks them up, as well as Vercel's KV_REST_API_URL / KV_REST_API_TOKEN. In development and tests it runs in memory without them. For Cloudflare Workers KV or a custom setup, pass a driver.
import { getKV } from 'payload-kv'
const kv = getKV(payload)
await kv.incr({ collection: 'posts', id, field: 'views' })
await kv.toggle({ collection: 'posts', id, field: 'likes', req }) // like / unlike as the current user
await kv.push({ collection: 'posts', id, field: 'comments', item: { body: 'Nice!' }, req })
Or from the browser, with access control applied: POST /api/posts/:id/kv/views/incr.
KV fields are Payload fields whose values live in KV. They have normal types, so generated types, GraphQL and the admin UI work as usual.
| Field | Reads as | Changes with |
|---|---|---|
kvCounter | a number | incr, set, clear |
kvValue | any field type (text, date, json…), optionally with a TTL | document saves, set, clear |
kvList | the newest items of a capped feed | push, remove, paged with list |
kvSet | a member count, or the members | add, remove, toggle |
kvSetHas | whether the current user is in a set ("liked by me") | — |
kvRef, kvJoin | relationships to and from KV collections | document saves / — |
Fields take the usual Payload options (access, hooks, admin, and required/validate for values), and TTLs take durations like '15m'.
getKV(payload) changes KV fields without a document save, with one atomic Redis command per write. The same operations are available as REST endpoints (/api/{collection}/:id/kv/:field/...) and as a GraphQL kv mutation. Access follows your collection rules: users must be able to read the document, writes need update access (or the field's writeAccess), and users can only add or remove themselves in sets.
→ Atomic API, REST and GraphQL
Add index: true, and KV fields work in where and sort, mixed freely with database conditions:
payload.find({
collection: 'posts',
where: { category: { equals: 'news' }, likes: { greater_than: 10 } },
sort: '-views',
})
Leaderboards page straight from the Redis index, and large result sets are answered database-first, so queries never send huge IN lists.
Collections that don't belong in your database, such as reservations, sessions, presence or carts, can live entirely in KV:
{
slug: 'reservations',
custom: { kv: { ttl: '15m', indexes: ['status'] } },
fields: [
{ name: 'status', type: 'select', options: ['held', 'confirmed'] },
{ name: 'post', type: 'relationship', relationTo: 'posts' },
],
}
It's a normal Payload collection: the admin UI, hooks, access control, validation, unique, and every API. Documents expire on their own, queries are planned against Redis indexes, and relationships work in both directions.
Turn on sync: true for a field, and the plugin keeps a copy in a hidden database column, written in batches by a Payload job or a cron endpoint. If Redis loses a key, reads fall back to the copy and restore it.
| Driver | Import | Best for |
|---|---|---|
| Upstash Redis | payload-kv/upstash | Everything; the recommended default |
| Vercel KV | payload-kv/vercel | The same, through Vercel's Marketplace |
| Cloudflare Workers KV | payload-kv/cloudflare | TTL values, cached data, lookups by id (no atomic counters) |
| Memory | payload-kv/memory | Tests and local development |
→ Drivers
kvPlugin() works with no options. Everything is tunable: key prefix, endpoints, query limits, sync schedule and more.
RateLimit-* headers and temporary blocks that admins can see and lift.Each example has its own README and end-to-end tests.
| Payload | 3 (≥ 3.94) and 4 (beta) |
| Databases | Postgres, SQLite, MongoDB |
| KV stores | Upstash Redis, Vercel KV, Cloudflare Workers KV, in-memory |
| Node | 22, 24, 26+ (as Payload requires) |
CI tests every Payload version, database and KV store on every change. payload-kv is pre-1.0, so minor versions may still change the API; the changelog lists every change.
Issues and pull requests are welcome. See CONTRIBUTING.md for setup, and TESTING.md for the test matrix.
Topics
payload upstash
Upstash Redis key-value adapter for Payload's built-in KV store
82333/wk7v3 v4
payloadcms redis plugin
Transparent Redis caching layer for Payload database queries with automatic invalidation on writes
42181/wk15v3
payload cache
Automatic Next.js 16 and Vercel cache tagging and invalidation for Payload reads
74321/wk0v3 v4
payload kv cloudflare
Payload KV adapter that stores key-value data in Cloudflare Workers KV
6663/wk0v3 v4
payload revalidate
Field-driven Next.js cache revalidation for Payload with id-keyed cached finders and a dependency map
59240/wk18v3
cached local api
Cache Payload Local API operations with Next.js unstable_cache and automatic tag-based revalidation
48112/wk335v3