Overview
The Upstash Redis client provides several configuration options to customize behavior for your environment and use case. Configuration varies slightly between platforms, but all platforms share common options.Basic configuration
Create a Redis client with your Upstash credentials:Get your credentials from the Upstash Console under your database details.
Configuration from environment variables
Load credentials automatically from environment variables:UPSTASH_REDIS_REST_URLorKV_REST_API_URLfor the URLUPSTASH_REDIS_REST_TOKENorKV_REST_API_TOKENfor the token
The
KV_* variables provide compatibility with Vercel KV and other platforms that use different naming conventions.Configuration options
Connection credentials
The REST URL for your Upstash Redis database. Find this in the Upstash Console under
UPSTASH_REDIS_REST_URL.The authentication token for your database. Find this in the Upstash Console under
UPSTASH_REDIS_REST_TOKEN.HTTP and retry options
Configure retry behavior for network errors.Set to RetryConfig properties:
false to disable retries:retries(number, default: 5): Maximum number of retry attemptsbackoff(function): Function that returns wait time in milliseconds given the retry count
Controls how response data is encoded for transfer.By default, the server base64-encodes responses to safely handle non-UTF8 data like emojis. For very large responses with guaranteed UTF8 data, you can disable this:
Configure HTTP cache behavior. Options:
"default", "force-cache", "no-cache", "no-store", "only-if-cached", "reload".Provide an AbortSignal to cancel in-flight requests.
Redis client options
Automatically deserialize JSON responses from Redis using
JSON.parse.Enable automatic command pipelining for improved performance. See auto-pipeline for details.
Ensure read-your-writes consistency. See read-your-writes for details.
Log the latency of each command to the console for debugging.
Send anonymous telemetry data to help improve the SDK. Collected data includes SDK version, platform, and runtime version.Disable telemetry:Or set the
UPSTASH_DISABLE_TELEMETRY environment variable:Node.js specific options
Provide a custom HTTP agent for connection reuse (Node.js only).
Enable HTTP keep-alive for connection reuse.
Platform-specific imports
Cloudflare Workers
Import from the Cloudflare-specific entrypoint:Node.js
Use the standard import:Advanced: custom requester
For advanced use cases, provide a customRequester implementation: