---
title: "User-Agent Based Rendering"
description: "Learn how to render a different page based on the User-Agent header."
url: "https://vercel.com/templates/next.js/edge-functions-user-agent-based-rendering"
links:
  repository: "https://github.com/vercel/examples/tree/main/edge-middleware/user-agent-based-rendering"
  demo: "https://edge-user-agent-based-rendering.vercel.app"
  deploy: "https://vercel.com/new/clone?demo-title=User-Agent+Based+Rendering&demo-description=Learn+how+to+render+a+different+page+based+on+the+User-Agent+header.&demo-url=https%3A%2F%2Fedge-user-agent-based-rendering.vercel.app&project-name=user-agent-based-rendering&repository-name=user-agent-based-rendering&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fedge-middleware%2Fuser-agent-based-rendering&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F3ozoROHRp7sWV4Z7ou8xLW%2F23c2a9ab90aa6cc706f3ac011f9c24c0%2Fedge-user-agent-based-rendering.vercel.app_.png"
---

# User-Agent Based Rendering

Learn how to render a different page based on the User-Agent header.

# User-Agent Based Rendering

This example shows how to render a different page based on the [User-Agent header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent).

## Demo

https://edge-user-agent-based-rendering.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/user-agent-based-rendering&project-name=user-agent-based-rendering&repository-name=user-agent-based-rendering)

### Clone and Deploy

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:

```bash
pnpm create next-app --example https://github.com/vercel/examples/tree/main/edge-middleware/user-agent-based-rendering
```

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.
