Registry / web-framework / connect-next

connect-next

JSON →
library4.0.1jsnpmunverified

connect-next is an actively maintained fork of the classic Connect middleware framework for Node.js, providing a high-performance, pluggable HTTP server framework built around a "middleware" stack. The current stable version is 4.0.1, released as part of an active development cadence. Key differentiators from the original Connect include a complete rewrite in TypeScript, native ES module (ESM) publication, and a stricter Node.js engine requirement (currently `^20.19.0 || >=22.12.0`). It also ships with its own TypeScript types, eliminating the need for `@types/connect`. The project modernizes the proven Connect architecture, ensuring compatibility with contemporary Node.js practices and providing a robust foundation for web applications.

npm install connect-next
INSTALL
IMPORT
SIG · CONNECT-NEXT
C
connect-next
web-frameworkjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect
import { connect } from 'connect-next';
import connect from 'connect-next';
Since v4, connect-next is a native ES module (ESM) and exposes a named 'connect' export, unlike the original 'connect' which used a default export.
connect (CommonJS)
N/A
const connect = require('connect-next');
connect-next is an ES module only. Direct CommonJS 'require()' is not supported; use dynamic import() if absolutely necessary within CJS contexts, or convert your project to ESM.
Middleware types
import type { IncomingMessage, ServerResponse } from 'node:http'; import type { NextFunction } from 'connect-next';
While 'NextFunction' is not directly exported, 'connect-next' ships with its own TypeScript types. Middleware typically takes (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void. 'NextFunction' represents (err?: any) => void.

Demonstrates creating a basic Connect-Next application, adding common middleware for compression, session management, and body parsing, then listening for HTTP requests.

import { connect } from 'connect-next'; import { createServer } from 'node:http'; import compression from 'compression'; import cookieSession from 'cookie-session'; import bodyParser from 'body-parser'; const app = connect(); // gzip/deflate outgoing responses app.use(compression()); // store session state in browser cookie app.use( cookieSession({ keys: ['secret1', 'secret2'], }), ); // parse urlencoded request bodies into req.body app.use(bodyParser.urlencoded({ extended: false })); // respond to all requests app.use((req, res) => { res.end('Hello from Connect!\n'); }); // create an HTTP server and listen on port 3000 createServer(app).listen(3000);
Debug
Known issues
breakingConnect-Next requires Node.js version `^20.19.0 || >=22.12.0`. Older Node.js versions are not supported and will result in errors upon installation or execution.
fix
Upgrade your Node.js environment to a compatible version.
affects: >=4.0.0
breakingConnect-Next is published as a native ES module (ESM) and only supports 'import' syntax. CommonJS 'require()' calls will fail.
fix
Ensure your project is configured for ESM (e.g., via `"type": "module"` in `package.json` or by using `.mjs` extensions) and use `import { connect } from 'connect-next';`.
affects: >=4.0.0
breakingWhen migrating from the original `connect` package, note that `connect-next` exposes a named `connect` export, not a default one. Additionally, `@types/connect` is no longer needed as types are included.
fix
Change `import connect from 'connect';` to `import { connect } from 'connect-next';` and remove `@types/connect` from your dependencies.
affects: >=4.0.0
gotchaError-handling middleware must explicitly take four arguments: `(err, req, res, next)`. Middleware with fewer arguments are treated as regular middleware and will not catch errors passed to `next()`.
fix
Define error middleware with the signature `(err: Error, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;`.
affects: >=4.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module ... connect-next/index.js from ... not supported.
Attempting to use CommonJS `require()` to import `connect-next`, which is a native ES module.
fix
Refactor your import statement from `const connect = require('connect-next');` to `import { connect } from 'connect-next';` and ensure your project uses ES modules.
TypeError: connect_next_1.default is not a function
You are attempting to use a default import for `connect-next`, but it only exposes a named `connect` export.
fix
Change your import statement from `import connect from 'connect-next';` to `import { connect } from 'connect-next';`.
SyntaxError: Must use import to load ES Module: ...connect-next/index.js
Your Node.js environment or file is configured for CommonJS, but `connect-next` is an ES module.
fix
Ensure your `package.json` has `"type": "module"` if you intend to use ESM globally, or use `.mjs` file extensions for individual ES module files. Always use `import { connect } from 'connect-next';`.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
Amazon
2
OpenAI (training)
1
Resources
connect-next — npm install connect-next · libregistry