Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/howard86/next-api-handler
lightweight nextjs api handler wrapper, portable & configurable for serverless environment
https://github.com/howard86/next-api-handler
api express nextjs serverless typescript
Last synced: 3 days ago
JSON representation
lightweight nextjs api handler wrapper, portable & configurable for serverless environment
- Host: GitHub
- URL: https://github.com/howard86/next-api-handler
- Owner: Howard86
- License: other
- Created: 2021-09-19T13:16:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T16:49:49.000Z (10 months ago)
- Last Synced: 2024-04-14T06:58:20.261Z (10 months ago)
- Topics: api, express, nextjs, serverless, typescript
- Language: TypeScript
- Homepage: https://next-api-handler.vercel.app
- Size: 2.34 MB
- Stars: 47
- Watchers: 3
- Forks: 2
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
[](https://packagephobia.com/result?p=next-api-handler)
[](https://circleci.com/gh/Howard86/next-api-handler/tree/main)
[](https://codecov.io/gh/Howard86/next-api-handler)
[](https://dashboard.cypress.io/projects/d5185e/runs)
## Lightweight and Portable [Next.js](https://nextjs.org) API builder
Building RESTful API routes in [Next.js](https://nextjs.org) with middleware support, predictable error handling and type-safe interfaces for client-server communication.
> Visit [https://next-api-handler.vercel.app](https://next-api-handler.vercel.app) to view the full documentation.
## Getting Started
**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(() => 'Hello World!')
.post(async (req) => createUser(req.body))
.delete(() => {
throw new ForbiddenException();
});export default router.build();
```## License
[MIT](/LICENSE)