# next-methods

> Split next.js handlers by http method.

Latest version **1.0.2** (published 2021-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-methods
pnpm add next-methods
yarn add next-methods
bun add next-methods
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-09-03 |
| First published | 2021-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | José F. Romaniello |
| Maintainers | jfromaniello |

## Links

- npm: https://www.npmjs.com/package/next-methods
- npm.io page: https://npm.io/package/next-methods

## Recent versions

- 1.0.2 (latest) — 2021-09-03
- 1.0.1 — 2021-09-03
- 1.0.0 — 2021-09-03

## README

Split next.js handlers by http methods

## Installation

```
npm i next-methods --save
```
## Usage

Usage:

```javascript
import { withMethodHandler } from 'next-methods';

export default withMethodHandler({
  'PUT': handlePut,
  'GET': handleGet,
);
```

Example combining with other wrappers:

```javascript
export default withApiAuthRequired(
  withMethodHandler({
    'PUT': handlePut,
    'GET': handleGet,
  })
);
```

By default it will return 404 for unhandled methods but you can override the behavior as follows:

```js
export default withMethodHandler({
  'PUT': handlePut,
  'GET': handleGet,
  'other': (req, res) => res.status(400).end()
);
```

## License

MIT 2021 - José F. Romaniello

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