@upstash/redis
is an HTTP/REST based Redis client for typescript, built on top
of Upstash REST API.
[!NOTE]
This project is in GA Stage.The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes. The Upstash team is committed to maintaining and improving its functionality.
It is the only connectionless (HTTP based) Redis client and designed for:
See the list of APIs supported.
npm install @upstash/redis
import { Redis } from "https://esm.sh/@upstash/redis";
Create a new redis database on upstash
import { Redis } from "@upstash/redis"
const redis = new Redis({
url: <UPSTASH_REDIS_REST_URL>,
token: <UPSTASH_REDIS_REST_TOKEN>,
})
// string
await redis.set('key', 'value');
let data = await redis.get('key');
console.log(data)
await redis.set('key3', 'value3', {ex: 1});
// sorted set
await redis.zadd('scores', { score: 1, member: 'team1' })
data = await redis.zrange('scores', 0, 100 )
console.log(data)
// list
await redis.lpush('elements', 'magnesium')
data = await redis.lrange('elements', 0, 100 )
console.log(data)
// hash
await redis.hset('people', {name: 'joe'})
data = await redis.hget('people', 'name' )
console.log(data)
// sets
await redis.sadd('animals', 'cat')
data = await redis.spop('animals', 1)
console.log(data)
We have a dedicated page for common problems. If you can't find a solution, please open an issue.
See the documentation for details.
Create a new redis database on upstash and copy the url and token
bun run test
bun run build
This library sends anonymous telemetry data to help us improve your experience. We collect the following:
You can opt out by setting the UPSTASH_DISABLE_TELEMETRY
environment variable
to any truthy value.
UPSTASH_DISABLE_TELEMETRY=1