Skip to main content

Vercel KV

Vercel KV is an edge-compatible, REST-based key-value store that works seamlessly with Vercel deployments. FrontMCP supports Vercel KV as an alternative to standard Redis for session storage and caching.

Zero Infrastructure

No Redis server to manage—Vercel handles everything

Edge Compatible

Works in Vercel Edge Functions and serverless environments

Auto-Configuration

Environment variables are set automatically when you connect a KV store

Drop-in Replacement

Switch from Redis with a single config change

When to Use Vercel KV

Use CaseVercel KVStandard Redis
Vercel deployment✅ Recommended⚠️ Requires external service
Edge Functions✅ Native support❌ Not supported
Self-hosted❌ Vercel only✅ Full control
Pub/Sub needed❌ Not supported✅ Native support
Resource subscriptions❌ Requires Redis✅ Full support

Quick Start

1

Create KV Store in Vercel

Go to your Vercel Dashboard → Storage → Create Database → KV
2

Connect to Project

Select your project and environment. Vercel automatically adds KV_REST_API_URL and KV_REST_API_TOKEN to your environment.
3

Configure FrontMCP

import 'reflect-metadata';
import { FrontMcp } from '@frontmcp/sdk';

@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  redis: {
    provider: 'vercel-kv',
  },
})
export default class Server {}
4

Deploy

vercel deploy

Configuration

Basic Configuration

@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  redis: {
    provider: 'vercel-kv',
    // Uses KV_REST_API_URL and KV_REST_API_TOKEN from environment
  },
})

Full Configuration

@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  redis: {
    provider: 'vercel-kv',
    url: process.env.KV_REST_API_URL,      // Optional: override env var
    token: process.env.KV_REST_API_TOKEN,  // Optional: override env var
    keyPrefix: 'myapp:',                   // Optional: namespace keys
    defaultTtlMs: 7200000,                 // Optional: 2 hour TTL
  },
})

Configuration Options

provider
'vercel-kv'
required
Selects Vercel KV as the storage provider.
url
string
default:"process.env.KV_REST_API_URL"
The Vercel KV REST API URL. Automatically set when you connect a KV store to your Vercel project.
token
string
default:"process.env.KV_REST_API_TOKEN"
The Vercel KV REST API token. Automatically set when you connect a KV store to your Vercel project.
keyPrefix
string
default:"'mcp:'"
Prefix added to all keys. Useful for namespacing when sharing a KV store across multiple apps.
defaultTtlMs
number
default:"3600000"
Default time-to-live in milliseconds for session data. Defaults to 1 hour.

Environment Variables

VariableRequiredDescription
KV_REST_API_URLYesREST API endpoint for your KV store
KV_REST_API_TOKENYesAuthentication token for your KV store
When you connect a Vercel KV store to your project, these environment variables are automatically added to your Vercel project settings. No manual configuration needed!

Vercel Dashboard Setup

1

Navigate to Storage

In your Vercel Dashboard, click Storage in the top navigation.
2

Create KV Database

Click Create Database and select KV (Durable Redis).
3

Name Your Store

Choose a name like frontmcp-sessions and select a region close to your deployment.
4

Connect to Project

Select your FrontMCP project and choose which environments (Production, Preview, Development) should have access.
5

Verify Environment Variables

Go to your project Settings → Environment Variables to confirm KV_REST_API_URL and KV_REST_API_TOKEN are set.

Usage with CachePlugin

Vercel KV works seamlessly with the CachePlugin using type: 'global-store':
import 'reflect-metadata';
import { FrontMcp, App } from '@frontmcp/sdk';
import { CachePlugin } from '@frontmcp/plugins';

@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  redis: {
    provider: 'vercel-kv',
  },
  apps: [MyApp],
})
export default class Server {}

@App({
  name: 'my-app',
  plugins: [
    CachePlugin.init({
      type: 'global-store',  // Uses the global redis config automatically
      defaultTTL: 3600,
    }),
  ],
})
class MyApp {}
The type: 'global-store' option allows plugins to automatically use whatever storage provider you’ve configured at the @FrontMcp level—whether it’s Redis or Vercel KV. No need to repeat configuration!

Comparison: Vercel KV vs Standard Redis

FeatureVercel KVStandard Redis
InfrastructureManaged by VercelSelf-managed or cloud service
Edge Compatible✅ Yes❌ No
Serverless Friendly✅ Optimized⚠️ Connection overhead
Pub/Sub❌ Not available✅ Full support
Resource Subscriptions❌ Not supported✅ Full support
Latency~5-15ms (REST)~1-5ms (TCP)
PricingPay per requestPay for instance
Setup ComplexityMinimalModerate

Limitations

Vercel KV has some limitations compared to standard Redis:
  1. No Pub/Sub Support: Vercel KV is REST-based and does not support Redis pub/sub. If your app uses resource subscriptions, you’ll need standard Redis.
  2. Higher Latency: REST API calls have slightly higher latency than direct Redis TCP connections. For most use cases, this difference is negligible.
  3. Vercel-Only: Vercel KV only works in Vercel deployments. For other platforms, use standard Redis.
  4. Request-Based Pricing: Unlike Redis instances with flat pricing, Vercel KV charges per request. High-traffic apps should evaluate costs.

Hybrid Configuration: Vercel KV + Redis

Need resource subscriptions but still want Vercel KV’s edge compatibility for sessions? Use the pubsub option to configure Redis specifically for pub/sub features while keeping Vercel KV for everything else.
import 'reflect-metadata';
import { FrontMcp, App } from '@frontmcp/sdk';
import { CachePlugin } from '@frontmcp/plugins';

@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  // Vercel KV for sessions and cache (edge-compatible)
  redis: {
    provider: 'vercel-kv',
  },
  // Redis for pub/sub features (resource subscriptions)
  pubsub: {
    host: process.env.REDIS_HOST,
    port: 6379,
    password: process.env.REDIS_PASSWORD,
  },
  apps: [MyApp],
})
export default class Server {}

@App({
  name: 'my-app',
  plugins: [
    // CachePlugin uses Vercel KV via global-store
    CachePlugin.init({ type: 'global-store' }),
  ],
})
class MyApp {}
The pubsub option only accepts Redis configuration—Vercel KV is not supported for pub/sub since it’s REST-based and doesn’t support the Redis pub/sub protocol.

When to Use Hybrid Configuration

ScenarioConfiguration
Sessions only, no subscriptionsredis: { provider: 'vercel-kv' }
Full Redis features neededredis: { host: '...' }
Edge sessions + Redis subscriptionsredis: { provider: 'vercel-kv' } + pubsub: { host: '...' }
When using hybrid configuration, you need a Redis service for pub/sub:
ProviderNotes
UpstashServerless Redis, pairs well with Vercel
Redis CloudManaged Redis Enterprise
AWS ElastiCacheAWS-managed Redis

Migration from Redis

Switching from standard Redis to Vercel KV requires only a configuration change:
@FrontMcp({
  info: { name: 'My Server', version: '1.0.0' },
  redis: {
    host: process.env.REDIS_HOST,
    port: 6379,
    password: process.env.REDIS_PASSWORD,
  },
})
The @vercel/kv package is an optional peer dependency. It’s only loaded when you use provider: 'vercel-kv', so it won’t affect bundle size for non-Vercel deployments.

Troubleshooting

Cause: The KV_REST_API_URL or KV_REST_API_TOKEN environment variables are not set.Solution:
  1. Ensure you’ve created a KV store in the Vercal Dashboard
  2. Connect the KV store to your project
  3. Check that environment variables are set in Project Settings → Environment Variables
  4. If running locally, add variables to your .env file
Cause: The @vercel/kv package is not installed.Solution:
npm install @vercel/kv
# or
yarn add @vercel/kv
Cause: Each serverless invocation may create a new connection.Solution: This is expected behavior. Vercel KV handles connection pooling internally. Ensure your session store is properly configured and defaultTtlMs is set appropriately.
Cause: Vercel KV does not support Redis pub/sub, which is required for resource subscriptions.Solution: Use standard Redis for apps that require resource subscription functionality. Consider a managed Redis service like Upstash or Redis Cloud.