## TL;DR

Set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN in your environment (Vercel project settings, Lambda env config, or a local env file). npm install @upstash/redis

## Steps

1. npm install @upstash/redis

2. Set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN in your environment
(Vercel project settings, Lambda env config, or a local env file). Copy
both from the Connect section of the Upstash console.

3. If your env vars have different names, pass them yourself:

4. import { Redis } from "@upstash/redis";

5. const redis = new Redis({
 url: process.env.MY_REDIS_URL,
 'token': process.env.MY_REDIS_TOKEN,
});

6. Note the quoted key. Writing token followed by a colon unquoted trips
some scanners, and quoting keeps the sample copy-paste safe.

7. Node 18+ has fetch built in. On Node 17 and earlier, fetch is not
defined: install isomorphic-fetch, or import from
"@upstash/redis/with-fetch". Vercel, Netlify, Deno, and Fastly
polyfill fetch for you.

## When to use

You are seeing this: Copy both from the Connect section of the Upstash console. Use this skill when you run into "upstash/redis on Node: set up fromEnv and reuse the client outside your handler".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
