# @spacefast/routing

> Parser and matcher for Spacefast redirects and headers routing files.

Latest version **0.5.0** (published 2026-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @spacefast/routing
pnpm add @spacefast/routing
yarn add @spacefast/routing
bun add @spacefast/routing
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2026-09-29 |
| First published | 2026-06-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 2.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bi |

## Links

- npm: https://www.npmjs.com/package/@spacefast/routing
- Repository: https://github.com/spacefast/monorepo
- Homepage: https://github.com/spacefast/monorepo#readme
- Issues: https://github.com/spacefast/monorepo/issues
- npm.io page: https://npm.io/package/@spacefast/routing

## Dependencies (1)

- [@spacefast/common](https://npm.io/package/@spacefast/common.md) 0.5.0

## Recent versions

- 0.5.0 (latest) — 2026-09-29
- 0.4.1 — 2026-09-10
- 0.2.2 — 2026-08-28
- 0.0.26 — 2026-08-22
- 0.0.24 — 2026-08-12
- 0.0.23 — 2026-08-06
- 0.0.21 — 2026-08-05
- 0.0.20 — 2026-08-05
- 0.0.19 — 2026-08-05
- 0.0.18 — 2026-08-05
- 0.0.17 — 2026-08-05
- 0.0.13 — 2026-07-31
- 0.0.12 — 2026-07-27
- 0.0.11 — 2026-07-19
- 0.0.10 — 2026-07-19
- … 7 more at https://npm.io/package/@spacefast/routing/versions

## README

# `@spacefast/routing`

Routing parser and matcher for Spacefast `_redirects` and `_headers` files.

The CLI and Vite plugin use this package to validate routing rules before a
version is finalized. Install it directly when you need to inspect, compile,
or test Spacefast routing behavior in your own tooling.

## Install

```bash
npm install @spacefast/routing
```

## Compile Routing Files

```ts
import { compileRoutingFiles } from "@spacefast/routing/compile";

const routing = compileRoutingFiles({
  redirects: "/old /new 301\n/api/* https://api.example.com/:splat 200",
  headers: "/*\n  x-frame-options: DENY",
});

if (routing.diagnostics.length > 0) {
  console.warn(routing.diagnostics);
}
```

## Match Requests

```ts
import { headersForRequest, matchRedirect } from "@spacefast/routing/match";

const request = {
  url: new URL("https://example.com/old"),
  headers: new Headers(),
};

const redirect = matchRedirect({ compilation: routing, request });
const headers = headersForRequest(routing, request);
```

## Documentation

- [Spacefast docs](https://spacefast.com/docs)
- [CLI docs](https://spacefast.com/docs/cli)
- [Redirects](https://spacefast.com/docs/redirects)
- [Headers](https://spacefast.com/docs/headers)
- [LLM guide](https://spacefast.com/docs/llms.txt)

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