npm

@lukeshay/next-router
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

@lukeshay/next-router

Adds basic routing to Next.js API routes. Also allows for wrapping handler functions to mutate the context that is being passed in.

Example

pages/api/hello.js:

import { router } from "@lukeshay/next-router";

const wrapper = (req, res, handler) => handler({ req, res, wrapped: true });

const get = (ctx) => ctx.res.json({ message: "Hello, World!" });

export default middleware(wrapper).get(get).handler();

Readme

Keywords

none

Package Sidebar

Install

npm i @lukeshay/next-router

Weekly Downloads

2

Version

0.5.0

License

MIT

Unpacked Size

16.4 kB

Total Files

16

Last publish

Collaborators

  • lukeshay