> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-dx-2866-inline-start-redis-snippet.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Deno Deploy

<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; 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.
</Tip>

This is a step-by-step guide on how to use Upstash Redis to create a view
counter in your Deno deploy project.

### Create a database

Create a Redis database using [Upstash Console](https://console.upstash.com) or
[Upstash CLI](https://github.com/upstash/cli). Select the global to minimize the
latency from all edge locations. Copy the `UPSTASH_REDIS_REST_URL` and
`UPSTASH_REDIS_REST_TOKEN` for the next steps.

### Create a Deno deploy project

Go to [https://dash.deno.com/projects](https://dash.deno.com/projects) and
create a new playground project.

<img src="https://mintcdn.com/upstash-dx-2866-inline-start-redis-snippet/_He9WU4MKVW7Xr7k/img/redis-deno/create.png?fit=max&auto=format&n=_He9WU4MKVW7Xr7k&q=85&s=65b2bc3495eb21658dff4996d689d1fb" alt="" width="2056" height="1308" data-path="img/redis-deno/create.png" />

### 2. Edit the handler function

Then paste the following code into the browser editor:

```ts theme={"system"}
import { serve } from "https://deno.land/std@0.142.0/http/server.ts";
import { Redis } from "https://deno.land/x/upstash_redis@v1.14.0/mod.ts";

serve(async (_req: Request) => {
  if (!_req.url.endsWith("favicon.ico")) {
    const redis = new Redis({
      url: "UPSTASH_REDIS_REST_URL",
      token: "UPSTASH_REDIS_REST_TOKEN",
    });

    const counter = await redis.incr("deno-counter");
    return new Response(JSON.stringify({ counter }), { status: 200 });
  }
});
```

### 3. Deploy and Run

Simply click on `Save & Deploy` at the top of the screen.

<img src="https://mintcdn.com/upstash-dx-2866-inline-start-redis-snippet/_He9WU4MKVW7Xr7k/img/redis-deno/deploy.png?fit=max&auto=format&n=_He9WU4MKVW7Xr7k&q=85&s=6282977f2be560d9b7039b72ba9c71d5" alt="" width="2962" height="1492" data-path="img/redis-deno/deploy.png" />
