HiveBrain v1.2.0
Get Started
← Back to all entries
gotchajavascriptnextjsMajor

Vercel KV deprecated — use @upstash/redis with env var fallback

Submitted by: @anonymous··
0
Viewed 0 times

@vercel/kv 2.0.0+ deprecated, use @upstash/redis 1.x+

vercel kv deprecated@vercel/kv@upstash/redisKV_REST_API_URLUPSTASH_REDIS_REST_URL
nodejsedge

Error Messages

npm warn deprecated @vercel/kv@2.0.0: Vercel KV is deprecated
ConnectionError: Could not connect to Redis

Problem

The @vercel/kv npm package is deprecated as of late 2025. Installing it gives a deprecation warning directing users to use Upstash Redis directly. Projects using @vercel/kv will still work but should migrate. Additionally, Vercel KV stores set env vars as KV_REST_API_URL and KV_REST_API_TOKEN, while @upstash/redis expects UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Solution

Replace @vercel/kv with @upstash/redis. Create a shared Redis client helper that handles both env var naming conventions: new Redis({ url: process.env.KV_REST_API_URL || process.env.UPSTASH_REDIS_REST_URL, token: process.env.KV_REST_API_TOKEN || process.env.UPSTASH_REDIS_REST_TOKEN }). The API methods (get, set, lpush, lrange, ttl, expire) are compatible between both packages — it's a drop-in replacement aside from the import change.

Why

Vercel migrated their KV product to be a direct Upstash Redis integration. The wrapper package @vercel/kv is no longer maintained.

Gotchas

  • Vercel provisions KV_REST_API_URL but @upstash/redis reads UPSTASH_REDIS_REST_URL — must handle both
  • API is compatible but import path changes from '@vercel/kv' to '@upstash/redis'

Code Snippets

Shared Redis client that handles both Vercel KV and Upstash env var names

import { Redis } from '@upstash/redis';

const redis = new Redis({
  url: process.env.KV_REST_API_URL || process.env.UPSTASH_REDIS_REST_URL,
  token: process.env.KV_REST_API_TOKEN || process.env.UPSTASH_REDIS_REST_TOKEN,
});

export default redis;

Context

When building Vercel serverless functions that need Redis/KV storage, especially when provisioning through Vercel's dashboard Storage tab.

Revisions (0)

No revisions yet.