SYSTEM Cited by 3 sources
OpenNext¶
OpenNext (opennext.js.org) is an open-source adapter layer that makes Next.js applications deployable on runtimes other than Vercel — including Cloudflare Workers, AWS Lambda, Netlify, and others. Historically Next.js has assumed Vercel-specific runtime primitives; OpenNext fills the gap so the same app can run cross-platform.
The Cloudflare-specific integration package is opennextjs-cloudflare.
Architecture role¶
OpenNext sits between:
- Above: the Next.js / React render pipeline (user code + Next.js framework + React SSR).
- Below: the host runtime's HTTP API (Workers'
Request/Response, Lambda's invocation protocol, etc.).
Its translation job includes: request/response shape adaptation, streaming response mechanics, the build step that produces runtime-compatible output, Next.js caching / revalidation glue, middleware integration, and cookie/header handling.
Inefficiencies surfaced by the 2025-10-14 benchmark¶
Cloudflare's Workers-team profiling of cf-vs-vercel-bench
flagged OpenNext (and some Next.js / React itself) as hot for
avoidable allocations and copies. Named findings:
pipeThrough()creating 50 × 2048-byteBufferinstances per render, whether they are actually used or not.opennextjs-cloudflareneedlessly copying every chunk of streamed output data as it exits the renderer and enters the Workers runtime. The benchmark returned 5 MB per request, so the copy cost compounded.Buffer.concat(chunks)called just to read.length. AgetBody()helper would concat all chunks into a single buffer and return it; callers doinggetBody().lengthjust wanted the byte count and discarded the buffer. An obvious fix.- Node.js streams ⇆ Web Streams adapters that double-buffer
(see concepts/stream-adapter-overhead) — e.g.
Readable.toWeb(Readable.from(res.getBody()))runs through both a Node stream's buffer and a Web stream's buffer. Replaceable withReadableStream.from(chunks). - Value-oriented
ReadableStreams with defaulthighWaterMark: 1in React/Next.js — every enqueued chunk is its own read, even for byte data where coalescing into 4096-byte blocks would be correct. - Dynamic-mode streaming vs static-mode buffering. When
OpenNext renders a page in non-
force-dynamicmode, the response is fully rendered into a single buffer before any bytes go out — catastrophic for TTFB benchmarks even though the CPU cost is no worse, just less stream-hidden.
Cloudflare began opening upstream PRs against OpenNext for these (patterns/upstream-the-fix).
Known performance bottleneck¶
Cloudflare's composable-cache implementation inside OpenNext (used to dedupe concurrent rendering requests for the same page) has pieces with performance issues Cloudflare explicitly names as "not going to impact the numbers for this particular set of benchmarks, we're working on improving those pieces also."
Seen in¶
- sources/2025-10-14-cloudflare-unpacking-cloudflare-workers-cpu-performance-benchmarks — canonical wiki instance of OpenNext adapter-layer surface- area analysis: Buffer allocation noise, streams-adapter double-buffering, value-vs-byte streams, and the dynamic-vs- static rendering difference that interacted with benchmark TTFB measurement.
- sources/2026-02-27-cloudflare-a-better-streams-api-is-possible-for-javascript
— same author (Snell) four months later: OpenNext's
stream-adapter cost is a symptom of the broader Web-streams
design problem. Streaming SSR through 3 transforms at 1 KB
chunks is quoted from Vercel's benchmark as 630 MB/s
(Web streams) vs ~7,900 MB/s (Node
pipeline()) — a 12× gap attributable almost entirely to promise and object allocation overhead. - sources/2026-02-24-cloudflare-how-we-rebuilt-nextjs-with-ai-in-one-week — structural superseding posture: rather than continue adapting Turbopack output, Cloudflare ships vinext — a clean reimplementation of the Next.js API surface on Vite. Names OpenNext's approach explicitly as "a difficult and fragile approach" that becomes "a game of whack-a-mole" because "OpenNext has to reverse-engineer Next.js's build output, this results in unpredictable changes between versions that take a lot of work to correct." Canonical wiki instance of patterns/clean-reimplementation-over-adapter. vinext's test suite includes "tests ported directly from … OpenNext's Cloudflare conformance suite" — the adapter project's tests inform the reimplementation without the adapter approach itself being retained.
Related¶
- systems/nextjs — the framework OpenNext ports.
- systems/cloudflare-workers — the host-runtime target that motivated the Cloudflare-specific adapter package.
- systems/nodejs — OpenNext's upstream runtime expectations; Node.js stream → Web stream adapter is the double-buffer surface.
- systems/web-streams-api — Workers-preferred streaming API that OpenNext adapts Node-stream-based Next.js code into.
- systems/new-streams — POC alternative streaming API; conversation-starter on what OpenNext-class adapters could be built on.
- systems/react — upstream framework whose SSR output OpenNext streams.
- concepts/stream-adapter-overhead — the Node↔Web stream adapter cost OpenNext's choice of plumbing has been paying unnecessarily.
- concepts/promise-allocation-overhead — the underlying cost surface amplified at OpenNext's per-chunk rate.
- patterns/upstream-the-fix — Cloudflare's mode of contribution (PRs upstream, not platform-private patches).