---
title: "Basic Auth Password Protection"
description: "Password protect pages in your application using Edge Middleware."
url: "https://vercel.com/templates/next.js/basic-auth-password"
links:
  repository: "https://github.com/vercel/examples/tree/main/edge-middleware/basic-auth-password"
  demo: "https://edge-functions-basic-auth-password.vercel.app"
  deploy: "https://vercel.com/new/clone?demo-title=Basic+Auth+Password+Protection&demo-description=Password+protect+pages+in+your+application+using+Edge+Middleware.&demo-url=https%3A%2F%2Fedge-functions-basic-auth-password.vercel.app&project-name=basic-auth-password&repository-name=basic-auth-password&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fedge-middleware%2Fbasic-auth-password&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F6xus8INJfeLVmnhmlYaLQE%2F6993959365947af9e30244a52c1d0626%2Fedge-functions-basic-auth-password.vercel.app_.png"
---

# Basic Auth Password Protection

Password protect pages in your application using Edge Middleware.

# Basic Auth Password Protection

Password protect pages in your application using Edge Middleware.

## Demo

https://edge-functions-basic-auth-password.vercel.app

Login credentials:

- Username: `4dmin`
- Password: `testpwd123`

## 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/git/external?repository-url=https://github.com/vercel/examples/tree/main/edge-middleware/basic-auth-password&project-name=basic-auth-password&repository-name=basic-auth-password)

### 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/basic-auth-password basic-auth-password
```

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

### [Auth for subdomains](https://vercel.com/templates/next.js/subdomains-auth)

Learn how to secure sub domains using Next.js and NextAuth.

---

## 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.
