# @netlify/redirect-matcher

> Netlify's redirect rule matcher, compiled to WebAssembly

Latest version **0.8.0** (published 2026-11-03) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @netlify/redirect-matcher
pnpm add @netlify/redirect-matcher
yarn add @netlify/redirect-matcher
bun add @netlify/redirect-matcher
```

## Health

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

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2026-11-03 |
| First published | 2026-10-02 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.12.0 |
| Dependencies | 0 |
| Unpacked size | 5.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Netlify Inc. |
| Maintainers | netlify-bot, mikewen, youvalv, serhalp-netlify, mlgualtieri-gatsby |

## Links

- npm: https://www.npmjs.com/package/@netlify/redirect-matcher
- npm.io page: https://npm.io/package/@netlify/redirect-matcher

## Recent versions

- 0.8.0 (latest) — 2026-11-03
- 0.7.0 — 2026-10-28
- 0.6.0 — 2026-10-27
- 0.4.2 — 2026-10-02
- 0.4.1 — 2026-10-02
- 0.4.0 — 2026-10-02

## README

# @netlify/redirect-matcher

Netlify's redirect rule matcher, compiled to WebAssembly, for matching requests
against Netlify redirect rules in local tooling.

```js
import { createMatcher } from '@netlify/redirect-matcher'

const matcher = await createMatcher(rules, { jwtSecret, jwtRoleClaim })
const result = matcher.match({ scheme: 'https', host, path, query, headers, cookies })

if (result?.type === 'match') {
  console.log(result.status, result.to)
}

matcher.close()
```

`rules` is the JSON produced by `@netlify/redirect-parser`, as a string or an
array. Rules that fail to parse are skipped and listed in
`matcher.parseErrors`. `match` returns `null` when nothing matched, and
`{ type: 'forcedNotFound' }` when a role-gated rule rejected the request and no
later rule matched.

`headers` and `cookies` may be plain objects or iterables of `[name, value]`
pairs, such as `Headers` or `Map`. Header names are matched case-insensitively,
so names that differ only in case collide, and the last one wins. A header
whose value is an array matches on its first element, and `null` or
`undefined` values are treated as absent.

Loading the matcher defines these globals, which Go's WebAssembly runtime
needs: `globalThis.Go`, `globalThis.__netlifyRedirectMatcher`, and, if they
are not already defined, stub `globalThis.fs` and `globalThis.path` objects.

Requires Node.js 22.12 or later.

---
_Source: https://npm.io/package/@netlify/redirect-matcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
