---
title: "Rewriting at the Edge using Upstash"
description: "Learn how to avoid calling several services by pre-checking stock at the edge using a redis cache."
url: "https://vercel.com/templates/next.js/edge-rewrites-upstash"
links:
  repository: "https://github.com/vercel/examples/tree/main/edge-middleware/rewrites-upstash"
  demo: "https://edge-rewrites-upstash.vercel.app"
  deploy: "https://vercel.com/new/clone?demo-title=Rewriting+at+the+Edge+using+Upstash&demo-description=Learn+how+to+avoid+calling+several+services+by+pre-checking+stock+at+the+edge+using+a+redis+cache.&demo-url=https%3A%2F%2Fedge-rewrites-upstash.vercel.app&project-name=rewrites-upstash&repository-name=rewrites-upstash&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fedge-middleware%2Frewrites-upstash&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F3QDSBei7b9AzAFKn2kIMmL%2F805e239d34dff56a265515e47a569c7f%2Fedge-rewrites-upstash.vercel.app_.png"
---

# Rewriting at the Edge using Upstash

Learn how to avoid calling several services by pre-checking stock at the edge using a redis cache.

# Rewrites with Upstash

This example shows how to avoid calling several services by pre-checking stock at the edge using a redis cache ([Upstash](https://upstash.com/)).

## Demo

https://edge-rewrites-upstash.vercel.app

## How to Use

You can choose from one of the following two methods to use this repository:

### One-Click Deploy

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/edge-middleware/rewrites-upstash&project-name=rewrites-upstash&repository-name=rewrites-upstash)

### Clone and Deploy

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [pnpm](https://pnpm.io/installation) to bootstrap the example:

```bash
pnpm create next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/rewrites-upstash rewrites-upstash
```

Next, run Next.js in development mode:

```bash
pnpm dev
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=edge-middleware-eap) ([Documentation](https://nextjs.org/docs/deployment)).

## Related Templates

### [A/B Testing Simple](https://vercel.com/templates/next.js/ab-testing-simple)

By A/B testing at the edge, you'll reduce CLS from client-loaded experiments and improve your site's performance with smaller JS bundles.

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
