# @koa/multer

> Route middleware for Koa that handles `multipart/form-data` using multer

Latest version **4.0.0** (published 2025-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @koa/multer
pnpm add @koa/multer
yarn add @koa/multer
bun add @koa/multer
```

## Health

**Score 33/100 (F)** — status: maintenance-mode.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-05-25 |
| First published | 2019-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/koa__multer) |
| Module format | CommonJS |
| Node | >= 18 |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 174 |
| Author | Fangdun Cai |
| Maintainers | niftylettuce, fengmk2, dead_horse, jongleberry, juliangruber, aaron, titanism, 3imed-jaberi, ljharb |
| Keywords | form, form-data, formdata, koa, middleware, multipart, post |

## Links

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-05-25
- 3.1.0 — 2025-03-27
- 3.0.2 — 2022-11-22
- 3.0.1 — 2022-11-22
- 3.0.0 — 2020-05-27
- 2.0.2 — 2019-12-21
- 2.0.1 — 2019-11-20
- 2.0.0 — 2019-06-28

## README

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

> Route middleware for Koa that handles `multipart/form-data` using [multer][]

[![NPM version][npm-img]][npm-url]
[![NPM Downloads][downloads-image]][npm-url]
[![Build status][actions-img]][actions-url]
[![Test coverage][coveralls-img]][coveralls-url]
[![Dependency status][david-img]][david-url]
[![License][license-img]][license-url]


## Call for Maintainers

This module is a fork of [koa-multer][], the most widely used multer middleware in the koa community.  Due to lack of maintenance, it was forked to the official Koa organization and is available under `@koa/multer` package name.


## Install

> Note that you must install either `multer@1.x` (Buffer) or `multer@2.x` (Streams):

```sh
npm install --save @koa/multer multer
```


## Usage

```js
const Koa = require('koa');
const Router = require('@koa/router');
const multer = require('@koa/multer');

const app = new Koa();
const router = new Router();
const upload = multer(); // note you can pass `multer` options here

// add a route for uploading multiple files
router.post(
  '/upload-multiple-files',
  upload.fields([
    {
      name: 'avatar',
      maxCount: 1
    },
    {
      name: 'boop',
      maxCount: 2
    }
  ]),
  ctx => {
    console.log('ctx.request.files', ctx.request.files);
    console.log('ctx.files', ctx.files);
    console.log('ctx.request.body', ctx.request.body);
    ctx.body = 'done';
  }
);

// add a route for uploading single files
router.post(
  '/upload-single-file',
  upload.single('avatar'),
  ctx => {
    console.log('ctx.request.file', ctx.request.file);
    console.log('ctx.file', ctx.file);
    console.log('ctx.request.body', ctx.request.body);
    ctx.body = 'done';
  }
);

// add the router to our app
app.use(router.routes());
app.use(router.allowedMethods());

// start the server
app.listen(3000);
```


## Contributors

| Name            | Website                         |
| --------------- | ------------------------------- |
| **Nick Baugh**  | <http://niftylettuce.com/>      |
| **Imed Jaberi** | <https://www.3imed-jaberi.com/> |


## License

[MIT](LICENSE) © Fangdun Cai


##

[npm-img]: https://img.shields.io/npm/v/@koa/multer.svg?style=flat-square

[npm-url]: https://npmjs.org/package/@koa/multer

[actions-img]: https://github.com/koajs/multer/actions/workflows/unit-tests.yaml/badge.svg

[actions-url]: https://github.com/koajs/multer/actions

[coveralls-img]: https://img.shields.io/coveralls/koajs/multer.svg?style=flat-square

[coveralls-url]: https://coveralls.io/r/koajs/multer?branch=master

[license-img]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square

[license-url]: LICENSE

[david-img]: https://img.shields.io/david/koajs/multer.svg?style=flat-square

[david-url]: https://david-dm.org/koajs/multer

[downloads-image]: https://img.shields.io/npm/dm/@koa/multer.svg?style=flat-square

[multer]: https://github.com/expressjs/multer

[koa-multer]: https://github.com/koa-modules/multer

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