fetch
api.
Please use the correct import when deploying to special platforms.
Node.js / Browser
Examples: Vercel, Netlify, AWS Lambda If you are running on nodejs you can setUPSTASH_REDIS_REST_URL
and
UPSTASH_REDIS_REST_TOKEN
as environment variable and create a redis instance
like this:
If you are running on nodejs v17 and earlier,
fetch
will not be natively
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
for you. But if you are running on bare node, you need to either specify a
polyfill yourself or change the import path slightly:Cloudflare Workers
Cloudflare handles environment variables differently than Node.js. Please addUPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
using
wrangler secret put ...
or in the cloudflare dashboard.
Afterwards you can create a redis instance:
Fastly
Fastly introduces a concept called backend. You need to configure a backend in yourfastly.toml
. An example can be found
here.
Until the fastly api stabilizes we recommend creating an instance manually: