# koa-router

> Router middleware for koa. Maintained by Forward Email and Lad.

Latest version **14.0.0** (published 2025-08-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install koa-router
pnpm add koa-router
yarn add koa-router
bun add koa-router
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 14.0.0 |
| Published | 2025-08-02 |
| First published | 2013-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/koa-router) |
| Module format | CommonJS |
| Node | >= 20 |
| Dependencies | 4 |
| Unpacked size | 33.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 910 |
| Author | Alex Mingoia |
| Maintainers | niftylettuce, 3imed-jaberi, titanism |
| Keywords | koa, middleware, route, router |

## Links

- npm: https://www.npmjs.com/package/koa-router
- Repository: https://github.com/koajs/router
- Issues: https://github.com/koajs/router/issues
- npm.io page: https://npm.io/package/koa-router

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.4.1
- [http-errors](https://npm.io/package/http-errors.md) ^2.0.0
- [koa-compose](https://npm.io/package/koa-compose.md) ^4.1.0
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^8.2.0

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 14.0.0 (latest) — 2025-08-02
- 8.0.0-alpha.1 (next) — 2018-04-28
- 13.1.1 — 2025-07-01
- 13.0.1 — 2024-09-13
- 11.0.2 — 2023-10-12
- 12.0.1 — 2023-10-12
- 12.0.0 — 2022-07-19
- 11.0.1 — 2022-07-04
- 11.0.0 — 2022-07-04
- 10.1.1 — 2021-08-22
- 10.0.0 — 2020-11-02
- 9.4.0 — 2020-08-14
- 9.1.0 — 2020-06-30
- 9.0.1 — 2020-05-30
- 8.0.8 — 2020-02-15
- … 78 more at https://npm.io/package/koa-router/versions

## README

# [@koa/router](https://github.com/koajs/router)

> Router middleware for [Koa](https://github.com/koajs/koa). Maintained by [Forward Email][forward-email] and [Lad][].

[![build status](https://github.com/koajs/router/actions/workflows/ci.yml/badge.svg)](https://github.com/koajs/router/actions/workflows/ci.yml)

<!-- [![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) -->

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
[![license](https://img.shields.io/github/license/koajs/router.svg)](LICENSE)


## Table of Contents

* [Features](#features)
* [Migrating to 7 / Koa 2](#migrating-to-7--koa-2)
* [Install](#install)
* [Typescript Support](#typescript-support)
* [API Reference](#api-reference)
* [Contributors](#contributors)
* [License](#license)


## Features

* Express-style routing (`app.get`, `app.put`, `app.post`, etc.)
* Named URL parameters
* Named routes with URL generation
* Match routes with specific host
* Responds to `OPTIONS` requests with allowed methods
* Support for `405 Method Not Allowed` and `501 Not Implemented`
* Multiple route middleware
* Multiple and nestable routers
* `async/await` support


## Migrating to 7 / Koa 2

* The API has changed to match the new promise-based middleware
  signature of koa 2. See the [koa 2.x readme](https://github.com/koajs/koa/tree/2.0.0-alpha.3) for more
  information.
* Middleware is now always run in the order declared by `.use()` (or `.get()`,
  etc.), which matches Express 4 API.


## Install

[npm][]:

```sh
npm install @koa/router
```


## Typescript Support

```sh
npm install --save-dev @types/koa__router
```


## API Reference

See [API Reference](./API.md) for more documentation.


## Contributors

| Name             |
| ---------------- |
| **Alex Mingoia** |
| **@koajs**       |
| **Imed Jaberi**  |


## License

[MIT](LICENSE) © Alex Mingoia


##

[forward-email]: https://forwardemail.net

[lad]: https://lad.js.org

[npm]: https://www.npmjs.com

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