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
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
- Go to your service in the Fastly web interface
- Navigate to Origins > Hosts
- Click Create a host
- Set the name to match your
backendparameter (e.g.,upstash-db) - 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:1. Use Fastly Config Stores (Recommended)
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.Related
- Fastly Example - Complete example on GitHub
- Fastly Guide - Step-by-step tutorial
- Configuration - Complete configuration reference