Skip to main content
The Upstash Redis SDK is optimized for Cloudflare Workers with a dedicated platform-specific build.

Installation

Quick Start

1

Import from the Cloudflare-specific path

Always use @upstash/redis/cloudflare when deploying to Cloudflare Workers. The default import is optimized for Node.js and may not work correctly.
2

Define your environment interface

3

Use Redis in your worker

Configuration Options

Using fromEnv() with Options

Environment Variables

1

Add secrets using Wrangler CLI

2

Or configure in wrangler.toml (for development)

Do not commit secrets to wrangler.toml. Use Wrangler secrets for production.

Environment Binding

Cloudflare Workers can bind environment variables in two ways: Pass the env object to Redis.fromEnv():

2. Global Variables

If you don’t pass the env object, the SDK will attempt to read from global variables:
Module workers with explicit env passing is the recommended approach for better type safety and clarity.

Complete Example

Telemetry

The SDK automatically reports "cloudflare" as the platform in telemetry data. To disable telemetry:
Or set the UPSTASH_DISABLE_TELEMETRY environment variable in your env object.