Skip to main content

Intro

Overview

Next REST Framework is an open-source, opinionated, lightweight, easy-to-use set of tools to build type-safe, self-documenting HTTP REST APIs with Next.js. Building OpenAPI specification-compliant REST APIs can be cumbersome and slow but Next REST Framework makes this easy with auto-generated OpenAPI documents and docs using TypeScript and object schemas.

Features

Lightweight, type-safe, easy to use

  • Designed to work with TypeScript so that your request bodies, responses, headers etc. are strongly typed.
  • Object-schema validation with Zod. The schemas are automatically converted to JSON schema format for the auto-generated OpenAPI specifications.
  • Supports auto-generated openapi.json and openapi.yaml documents for which you can include your existing OpenAPI specification.
  • Works with Next.js Middleware and other server-side libraries, like NextAuth.js.
  • Supports both Next.js App Router and Pages Router, even at the same time.
  • Fully customizable - You can decide which routes Next REST Framework will use to serve your API docs etc. and it can be easily customized to work with any kind of existing Next.js REST API.

Installation

npm install --save next-rest-framework