Lightweight and Portable Next.js API builder
npm install next-api-handler---




!Known Vulnerabilities
Building RESTful API routes in Next.js with middleware support, predictable error handling and type-safe interfaces for client-server communication.
> Visit https://next-api-handler.vercel.app to view the full documentation.
TL;DR
``sh`
npm install next-api-handler # or yarn, pnpm
`ts
// in /pages/api/users.ts
import { RouterBuilder, ForbiddenException } from 'next-api-handler';
import { createUser, type User } from '@/services/user';
const router = new RouterBuilder();
router
.get
.post
.delete(() => {
throw new ForbiddenException();
});
export default router.build();
``