A TypeScript-ready, minimal router and middleware layer for Next.js, Edge API Routes, App Router, Middleware, and getServerSideProps.
next-connect is a minimal, promise-based router and middleware layer built for Next.js applications. It enables developers to structure API routes, edge functions, and server-side logic with an Express.js-like syntax while being optimized for serverless and edge environments. It solves the need for a lightweight, performant routing solution within Next.js's ecosystem.
Next.js developers building API routes, edge functions, middleware, or server-rendered pages who want a structured, middleware-based approach to handling requests.
Developers choose next-connect for its performance advantages over Express.js in serverless contexts, its seamless integration with Next.js features like Edge API Routes and App Router, and its TypeScript-first design with familiar middleware patterns.
The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarked as faster than Express.js with a minimal bundle size, making it ideal for serverless and edge runtimes where performance is critical.
Provides an Express.js-like API and can wrap existing Express middleware using expressWrapper, easing migration from Express.js to Next.js.
Built with full TypeScript support, ensuring type-safe routing and middleware throughout development, as evidenced by the code examples.
Works across all Next.js contexts including API Routes, Edge API Routes, App Router, Middleware, and getServerSideProps, offering consistent patterns.
Requires strict adherence to awaiting next() in middleware to avoid unhandled promise rejections, a common error highlighted in the documentation that can lead to bugs.
While compatible with Express.js via wrappers, it lacks a built-in ecosystem of middleware, often requiring custom implementations or dependency on external packages.
Tightly coupled to Next.js, so major updates to Next.js's API could necessitate changes or cause breaking compatibility issues, as seen with evolving features like App Router.
next-connect is an open-source alternative to the following products: