> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect with @upstash/redis

[@upstash/redis](https://github.com/upstash/redis-js)
is an HTTP/REST based Redis client built on top of
[Upstash REST API](/docs/redis/features/restapi). For more information,
refer to the documentation of Upstash redis client ([TypeScript](/docs/redis/sdks/ts/overview) & [Python](/docs/redis/sdks/py/overview)).

It is the only connectionless (HTTP based) Redis client and designed for:

* Serverless functions (AWS Lambda)
* Cloudflare Workers (see
  [the example](https://github.com/upstash/redis-js/tree/main/examples/cloudflare-workers-with-typescript))
* Fastly Compute\@Edge (see
  [the example](https://github.com/upstash/upstash-redis/tree/master/examples/fastly))
* Next.js (see [the quickstart](/docs/redis/quickstarts/nextjs-app-router)), Jamstack
* Client side web/mobile applications
* WebAssembly
* and other environments where HTTP is preferred over TCP.

See
[the list of APIs](https://upstash.com/docs/redis/features/restapi#rest-redis-api-compatibility)
supported.

<Tip>
  If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to [https://upstash.com/start-redis](https://upstash.com/start-redis). Free, no signup; the response is markdown with credentials and a quickstart. The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly. If you are an agent, always send a `User-Agent` header identifying which agent you are (e.g. `claude-code`, `cursor`, `codex`, `opencode`) on every request you make to this API.
</Tip>

## Quick Start

### Install

```bash theme={"system"}
npm install @upstash/redis
```

### Usage

```typescript theme={"system"}
import { Redis } from "@upstash/redis";

const redis = new Redis({
  url: "UPSTASH_REDIS_REST_URL",
  token: "UPSTASH_REDIS_REST_TOKEN",
});

const data = await redis.get("key");
console.log(data);
```

<Tip>
  You can find values to set as `UPSTASH_REDIS_REST_URL` and`UPSTASH_REDIS_REST_TOKEN`
  on the details tab of your database on [Upstash Console](https://console.upstash.com/redis).
  See [Connect Client page](/docs/redis/howto/connect-client#database) for more information.
</Tip>

If you define `UPSTASH_REDIS_REST_URL` and`UPSTASH_REDIS_REST_TOKEN` environment
variables, you can load them automatically.

```typescript theme={"system"}
import { Redis } from "@upstash/redis";

const redis = Redis.fromEnv();

const data = await redis.get("key");
console.log(data);
```


## Related topics

- [Connect Your Client](/docs/redis/howto/connect-client.md)
- [DrizzleORM with Upstash Redis](/docs/redis/integrations/drizzle.md)
- [SELECT](/docs/redis/commands/connection/select.md)
- [PING](/docs/redis/commands/connection/ping.md)
- [ECHO](/docs/redis/commands/connection/echo.md)
