# basic-auth-for-vercel-middleware

> Basic Authentication for vercel middleware

Latest version **1.0.12** (published 2026-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install basic-auth-for-vercel-middleware
pnpm add basic-auth-for-vercel-middleware
yarn add basic-auth-for-vercel-middleware
bun add basic-auth-for-vercel-middleware
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2026-09-11 |
| First published | 2022-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | mosle |
| Maintainers | mosle |
| Keywords | basicauth, auth, vercel, pages, middleware, functions |

## Links

- npm: https://www.npmjs.com/package/basic-auth-for-vercel-middleware
- Repository: https://github.com/mosle/basic-auth-for-vercel-middleware
- Homepage: https://github.com/mosle/basic-auth-for-vercel-middleware#readme
- Issues: https://github.com/mosle/basic-auth-for-vercel-middleware/issues
- npm.io page: https://npm.io/package/basic-auth-for-vercel-middleware

## Dependencies (1)

- [@vercel/edge](https://npm.io/package/@vercel/edge.md) ^1.3.3

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2026-09-11
- 1.0.9 — 2024-11-25
- 1.0.8 — 2024-09-02
- 1.0.7 — 2024-07-16
- 1.0.6 — 2024-07-16
- 1.0.5 — 2023-04-12
- 1.0.2 — 2023-04-12
- 1.0.1 — 2022-08-29
- 1.0.0 — 2022-08-29

## README

Basic Authentication for vercel middleware

## Installation

```sh
npm install --save basic-auth-for-vercel-middleware
```

```sh
yarn add basic-auth-for-vercel-middleware
```

## Usage

### add "PROJECT_ROOT/middleware.(js | ts)"

directory structure:

```
├── ...
├── middleware.js
└── ...
```

### edit "PROJECT_ROOT/middleware.(js | ts)"

like

```js
import { createBasicAuthHandler } from "basic-auth-for-vercel-middleware";
export default createBasicAuthHandler({ name: "test", password: "test" });

//if you use matcher
/*
export const config = {
  matcher: "/",
};
*/
```

```js
import { createBasicAuthHandler } from "basic-auth-for-vercel-middleware";
export default createBasicAuthHandler(
  { name: "test", password: "test" },
  "message for auth"
);
```

```js
//3rd parameter is skip flag(function or boolean)
import { createBasicAuthHandler } from "basic-auth-for-vercel-middleware";
export default createBasicAuthHandler(
  { name: "test", password: "test" },
  "message for auth",
  (request) =>
    request.headers.get("user-agent")?.includes("user-agent-for-cdn-robot")
);
```

---
_Source: https://npm.io/package/basic-auth-for-vercel-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
