Upstash
Last updated Apr 23, 2026 is a serverless database with Redis* and Kafka API. Upstash also offers QStash, a task queue/scheduler designed for the serverless.
Upstash for Redis
To set up an integration with Upstash:
- You need an existing Upstash database to connect to. Create an Upstash database ↗︎ or load data from an existing database to Upstash ↗︎.
- Insert some data to your Upstash database. You can add data to your Upstash database in two ways:
- Use the CLI directly from your Upstash console.
- Alternatively, install redis-cli ↗︎ locally and run the following commands.
sh
set GB "Ey up?"
sh
OK
sh
set US "Yo, what’s up?"
sh
OK
sh
set NL "Hoi, hoe gaat het?"
sh
OK
- Configure the Upstash Redis credentials in your Worker:
You need to add your Upstash Redis database URL and token as secrets to your Worker. Get these from your Upstash Console ↗︎ under your database details, then add them as secrets using Wrangler:
```sh # Add the Upstash Redis URL as a secret npx wrangler secret put UPSTASH_REDIS_REST_URL # When prompted, paste your Upstash Redis REST URL
# Add the Upstash Redis token as a secret npx wrangler secret put UPSTASH_REDIS_REST_TOKEN # When prompted, paste your Upstash Redis REST token ```
- In your Worker, install the
@upstash/redis, a HTTP client to connect to your database and start manipulating data:npmyarnpnpmbun
npm i @upstash/redis
yarn add @upstash/redis
pnpm add @upstash/redis
bun add @upstash/redis
- The following example shows how to make a query to your Upstash database in a Worker. The credentials needed to connect to Upstash have been added as secrets to your Worker.
```js import { Redis } from "@upstash/redis/cloudflare";
export default { async fetch(request, env) { const redis = Redis.fromEnv(env);
const country = request.headers.get("cf-ipcountry");
if (country) {
const greeting = await redis.get(country);
if (greeting) {
return new Response(greeting);
}
}
return new Response("Hello What's up!");
},
}; ```
Note
Redis.fromEnv(env) automatically picks up the default url and token names created in the integration.
If you have renamed the secrets, you must declare them explicitly like in the Upstash basic example ↗︎.
To learn more about Upstash, refer to the Upstash documentation ↗︎.
Upstash QStash
To set up an integration with Upstash QStash:
- Configure the publicly available HTTP endpoint ↗︎ that you want to send your messages to.
- Configure the Upstash QStash credentials in your Worker:
You need to add your Upstash QStash token as a secret to your Worker. Get your token from your Upstash Console ↗︎ under QStash settings, then add it as a secret using Wrangler:
sh
# Add the QStash token as a secret
npx wrangler secret put QSTASH_TOKEN
# When prompted, paste your QStash token
- In your Worker, install the
@upstash/qstash, a HTTP client to connect to your database QStash endpoint:npmyarnpnpmbun
npm i @upstash/qstash
yarn add @upstash/qstash
pnpm add @upstash/qstash
bun add @upstash/qstash
- Refer to the Upstash documentation on how to receive webhooks from QStash in your Cloudflare Worker ↗︎.
* Redis is a trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Upstash is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Upstash.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/databases/third-party-integrations/upstash/#page","headline":"Upstash","description":"Connect Cloudflare Workers to Upstash for serverless Redis and Kafka integrations.","url":"https://developers.cloudflare.com/workers/databases/third-party-integrations/upstash/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/databases/third-party-integrations/upstash/og.png?v=6743cffc86568ec9","dateModified":"2026-04-23","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Connect Cloudflare Workers to a Xata PostgreSQL database using Hyperdrive. title: Xata image: https://developers.cloudflare.com/workers/databases/third-party-integrations/xata/og.png?v=e9b06353781c703a
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.
Docs