Skip to main content
The Upstash Redis SDK works seamlessly with Fastly Compute@Edge, allowing you to use Redis at the edge.

Installation

Quick Start

1

Import from the Fastly-specific path

Always use @upstash/redis/fastly when deploying to Fastly Compute@Edge.
2

Configure a backend in fastly.toml

Create or update your fastly.toml file to define your Upstash Redis backend:
The backend name (e.g., upstash-db) must match the backend parameter in your Redis configuration.
3

Create a Redis instance

4

Use Redis in your handler

Configuration Options

The backend parameter is required for Fastly Compute@Edge and must match a backend defined in your fastly.toml file.

Complete Example

Project Structure

fastly.toml

src/index.js

Backend Configuration

Fastly requires you to define backends for external services. Backends can be configured:

1. In fastly.toml (Local Development)

2. Via Fastly CLI

3. Via Fastly Web Interface

  1. Go to your service in the Fastly web interface
  2. Navigate to Origins > Hosts
  3. Click Create a host
  4. Set the name to match your backend parameter (e.g., upstash-db)
  5. Set the address to your Upstash Redis URL

Environment Variables

Fastly Compute@Edge doesn’t have built-in environment variable support like other platforms. You have several options: Config stores allow you to manage configuration separately from your code.

2. Use Fastly Edge Dictionaries

Edge dictionaries provide key-value storage for configuration.

3. Build-time Environment Variables

Use webpack or your bundler to inject values at build time:

Deployment

1

Build your application

2

Deploy to Fastly

Telemetry

The SDK automatically reports "fastly" as the platform in telemetry data.
Telemetry cannot be disabled via environment variables in Fastly. Set enableAutoPipelining: false in the Redis constructor if needed.