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

# Vercel Functions

<Info>
  This is a quickstart for Vercel Serverless Functions. For Vercel Edge
  Functions, check [this
  article](https://upstash.com/blog/getstarted-nextjs-edge-with-redis).
</Info>

### Database Setup

Create a Redis database using [Upstash Console](https://console.upstash.com) or
[Upstash CLI](https://github.com/upstash/cli). Select the same region with your
Vercel Serverless Function to minimize the latency. Copy the
`UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` for the next steps.

### Project Setup

We will create a Next.js application and deploy to Vercel.

```shell
npx create-next-app@latest
cd my-app
```

Install @upstash/redis:

```shell
npm install @upstash/redis
```

### The Code

Update `app/api/hello.js` with the template below to test the Redis client:

```js app/api/hello.js
import { Redis } from "@upstash/redis";
import type { NextApiRequest, NextApiResponse } from "next";

const redis = Redis.fromEnv();

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
): Promise<void> {
  const count = await redis.incr("counter");
  res.status(200).json({ count });
}
```

### Configure the Credentials

We'll place the credentials in the `.env` file as below:

```text .env
UPSTASH_REDIS_REST_URL=<YOUR_URL>
UPSTASH_REDIS_REST_TOKEN=<YOUR_TOKEN>
```

### Run & Deploy

You can run the app locally: `npm run dev` and check
`http://localhost:3000/api/hello`

Deploy your app with `vercel deploy`

<Info>
  You can also integrate your Vercel projects with Upstash using Vercel
  Integration module. Check [this article](../howto/vercelintegration).
</Info>
