|
Redis-compatible cache for Next.js with TTL support, rate limiting, and session management via Vercel KV and Upstash.
Supports core Redis operations: strings, hashes, sorted sets, lists, and pipelines for batch commands with automatic performance optimization
Built-in TTL management prevents memory leaks; use setex() for temporary data and namespaced keys (user:123, ratelimit:ip:endpoint) to avoid collisions
Common patterns include cache-aside retrieval, atomic rate limiting with sliding windows, and distributed locks for race condition prevention
Known issues documented: environment variable setup in monorepos, JSON serialization constraints (no BigInt/circular refs), scanIterator() infinite loops in v2.0.0+, and Next.js caching quirks requiring unstable_noStore()
Redis Streams not supported; use @upstash/redis directly for XREAD/XADD operations
Vercel KV
Last Updated: 2026-01-21
Version: @vercel/kv@3.0.0 (Redis-compatible, powered by Upstash)
Quick Start
# Create KV: Vercel Dashboard → Storage → KV
vercel env pull .env.local # Creates KV_REST_API_URL and KV_REST_API_TOKEN
npm install @vercel/kv
Basic Usage:
import { kv } from '@vercel/kv';don't have the plugin yet? install it then click "run inline in claude" again.