AIを使って1週間でNext.jsを再構築した方法
エンジニアがAIを活用し、Next.jsをVite上で1週間で再構築。vinextは最大4倍高速なビルド、57%小さなバンドル、ワンコマンドでCloudflare Workersにデプロイ可能。
キーポイント
AIを活用して1週間でNext.jsを再実装した新フレームワーク「vinext」を開発
ViteベースでNext.js APIを再実装し、Cloudflare Workersにワンコマンドでデプロイ可能
従来のアダプター方式の課題を解決し、ビルド速度4倍・バンドルサイズ57%削減を実現
開発コストは約1,100ドルで、既に本番環境で稼働中
影響分析・編集コメントを表示
影響分析
この記事は、AIを活用したソフトウェア開発の効率化が現実のものとなりつつあることを示す重要な事例です。従来のフレームワーク互換性問題を根本から解決するアプローチは、フロントエンド開発のパラダイムシフトを促す可能性があります。また、低コストでの迅速な開発実現は、AI活用の経済的メリットを具体的に示しています。
編集コメント
AIを活用した実用的な開発事例として、技術的革新とビジネス的価値の両面で注目に値する内容です。特に、既存の互換性問題を根本から解決するアプローチが興味深い。
AIを使って1週間でNextjsを再構築した方法
Steve Faulkner
*この投稿はPT午後12時35分に更新され、ビルド時間のベンチマークにおける誤字を修正しました。
先週、1人のエンジニアとAIモデルが最も人気のあるフロントエンドフレームワークを一から再構築しました。その結果が「vinext」(発音は「ヴィー・ネクスト」)です。これはVite上に構築されたNext.jsの代替品で、単一のコマンドでCloudflare Workersにデプロイできます。初期のベンチマークでは、本番アプリのビルドが最大4倍高速化され、クライアントバンドルサイズが最大57%削減されました。そして、すでに本番環境で実行している顧客もいます。
この全体のコストは、トークン換算で約1,100ドルでした。
Next.jsのデプロイ問題
Next.jsは最も人気のあるReactフレームワークです。何百万人もの開発者が使用しており、ウェブの本番環境の大部分を支える正当な理由があります。開発者体験は最高水準です。
しかし、Next.jsには、より広範なサーバーレスエコシステムで使用する際にデプロイの問題があります。ツーリングは完全に特注品です。Next.jsはTurbopackに多大な投資をしていますが、Cloudflare、Netlify、AWS Lambdaにデプロイしたい場合、そのビルド出力を取得し、ターゲットプラットフォームが実際に実行できる何かに再形成する必要があります。
「OpenNextがその役割を果たすのでは?」と考えているなら、その通りです。
まさにそれがOpenNextが解決するために構築された問題です。Cloudflareを含む複数のプロバイダーから、OpenNextには多くのエンジニアリング努力が注がれてきました。それは機能しますが、すぐに制限にぶつかり、いたちごっこのゲームになってしまいます。
Next.jsの出力を基盤としてその上に構築することは、困難で脆弱なアプローチであることが証明されています。OpenNextはNext.jsのビルド出力をリバースエンジニアリングする必要があるため、バージョン間で予測不可能な変更が生じ、それを修正するには多くの作業が必要になります。
Next.jsは第一級のアダプターAPIに取り組んでおり、私たちもそれについて彼らと協力しています。これはまだ初期段階の取り組みですが、アダプターがあったとしても、依然として特注のTurbopackツールチェーンの上に構築することになります。そしてアダプターはビルドとデプロイのみをカバーします。開発中、next devはNode.jsでのみ排他的に実行され、異なるランタイムを接続する方法はありません。アプリケーションがDurable Objects、KV、AIバインディングなどのプラットフォーム固有のAPIを使用する場合、回避策なしでは開発環境でそのコードをテストできません。
vinextの紹介
Next.jsの出力を適応させる代わりに、Next.jsのAPIサーフェスをVite上で直接再実装したらどうでしょうか?ViteはNext.js以外のフロントエンドエコシステムの大部分で使用されているビルドツールで、Astro、SvelteKit、Nuxt、Remixなどのフレームワークを支えています。単なるラッパーやアダプターではなく、クリーンな再実装です。正直なところ、うまくいくとは思いませんでした。しかし、今は2026年であり、ソフトウェア構築のコストは完全に変わっています。
私たちは予想以上に進展しました。
npm install vinext
vinext dev # ホットモジュールリプレースメント付き開発サーバー
vinext build # 本番ビルド
vinext deploy # Cloudflare Workersへのビルドとデプロイ
これはNext.jsとTurbopack出力のラッパーではありません。APIサーフェスの代替実装です:ルーティング、サーバーレンダリング、React Server Components、サーバーアクション、キャッシング、ミドルウェア。これらすべてがプラグインとしてVite上に構築されています。最も重要なのは、Vite Environment APIのおかげで、Vite出力はあらゆるプラットフォームで実行できることです。
初期のベンチマークは有望です。33のルートを持つ共有App Routerアプリケーションを使用して、vinextをNext.js 16と比較しました。両フレームワークは同じ作業を行っています:コンパイル、バンドル、サーバーレンダリングされたルートの準備。Next.jsのビルドではTypeScriptの型チェックとESLintを無効にし(Viteはビルド中にこれらを実行しません)、force-dynamicを使用してNext.jsが静的ルートのプリレンダリングに余分な時間を費やさないようにしました(これにより不公平に速度が低下するのを防ぐためです)。目標は、バンドラーとコンパイル速度のみを測定することであり、それ以外はありません。ベンチマークはGitHub CI上で、mainへのすべてのマージ時に実行されます。
本番ビルド時間:
Next.js 16.1.6 (Turbopack)
vinext (Vite 7 / Rollup)
vinext (Vite 8 / Rolldown)
クライアントバンドルサイズ (gzip圧縮後):
vinext (Rollup)
vinext (Rolldown)
これらのベンチマークは、コンパイルとバンドリングの速度を測定しており、本番環境でのサービス提供パフォーマンスではありません。テストフィクスチャは単一の33ルートアプリであり、すべての本番アプリケーションを代表するサンプルではありません。これら3つのプロジェクトが開発を続けるにつれて、これらの数値は変化すると予想しています。完全な方法論と過去の結果は公開されています。決定的なものではなく、方向性を示すものとして捉えてください。
とはいえ、その方向性は励みになります。Viteのアーキテクチャ、特にRolldown(Vite 8で導入予定のRustベースのバンドラー)は、ビルドパフォーマンスにおいて構造的な利点があり、それがここではっきりと表れています。
Cloudflare Workersへのデプロイ
vinextは、最初のデプロイターゲットとしてCloudflare Workersを念頭に置いて構築されています。単一のコマンドで、ソースコードから実行中のWorkerへと移行できます。
これによりすべてが処理されます:アプリケーションのビルド、Worker設定の自動生成、デプロイ。App RouterとPages Routerの両方がWorkers上で動作し、完全なクライアントサイドハイドレーション、インタラクティブコンポーネント、クライアントサイドナビゲーション、React状態が利用できます。
本番環境のキャッシングについては、vinextにはISR(増分的静的再生成)をすぐに利用できるCloudflare KVキャッシュハンドラーが含まれています。
import { KVCacheHandler } from "vinext/cloudflare";
import { setCacheHandler } from "next/cache";
setCacheHandler(new KVCacheHandler(env.MY_KV_NAMESPACE));
KVはほとんどのアプリケーションにとって適切なデフォルトですが、キャッシングレイヤーは差し替え可能に設計されています。そのsetCacheHandler呼び出しは、理にかなったバックエンドを何でも交換できることを意味します。大きなキャッシュペイロードや異なるアクセスパターンを持つアプリには、R2の方が適しているかもしれません。また、設定を減らしながら強力なキャッシングレイヤーを提供するべきCache APIの改善にも取り組んでいます。目標は柔軟性です:あなたのアプリに合ったキャッシング戦略を選択してください。
現在実行中のライブ例:
App Router Playground
Hacker Newsクローン
App Router最小構成
Pages Router最小構成
また、Cloudflare AgentsがNext.jsアプリ内で実行されているライブ例もあります。これは、アプリ全体が開発フェーズとデプロイフェーズの両方でworkerd内で実行されるようになったため、getPlatformProxyのような回避策を必要としません。これは、妥協することなく、Durable Objects、AIバインディング、およびその他のすべてのCloudflare固有のサービスを使用できることを意味します。こちらをご覧ください。
フレームワークはチームスポーツ
現在のデプロイターゲットはCloudflare Workersですが、それは全体像のごく一部です。vinextの約95%は純粋なViteです。ルーティング、モジュールのシャイム、SSRパイプライン、RSC統合:どれもCloudflare固有のものではありません。
Cloudflareは、他のホスティングプロバイダーと協力し、彼らの顧客向けにこのツールチェーンを採用することを検討しています(作業は最小限です — Vercelでの概念実証を30分以内に動作させました!)。これはオープンソースプロジェクトであり、長期的な成功のためには、エコシステム全体のパートナーと協力して継続的な投資を確保することが重要であると信じています。他のプラットフォームからのプルリクエストは歓迎します。デプロイターゲットを追加することに興味がある場合は、イシューを開くか連絡してください。
ステータス: 実験的
明確にしておきたいのですが:vinextは実験的です。誕生してから1週間も経っておらず、大規模な意味のあるトラフィックでの実戦テストはまだ行われていません。本番アプリケーションで評価する場合は、適切な注意を払って進めてください。
とはいえ、テストスイートは広範です:1,700以上のVitestテストと380のPlaywright E2Eテストがあり、Next.jsテストスイートとOpenNextのCloudflare適合性テストスイートから直接移植されたテストを含みます。Next.js App Router Playgroundに対して検証を行いました。カバレッジはNext.js 16 APIサーフェスの94%に達しています。実際の顧客からの初期結果は励みになるものです。私たちは、すべての政府インターフェースを近代化することを目指すチーム、National Design Studioと協力し、彼らのベータサイトの1つであるCIO.govに取り組んでいます。彼らはすでにvinextを本番環境で実行しており、有意な改善を
原文を表示
How we rebuilt Next.js with AI in one week
Steve Faulkner
*This post was updated at 12:35 pm PT to fix a typo in the build time benchmarks.
Last week, one engineer and an AI model rebuilt the most popular front-end framework from scratch. The result, vinext (pronounced "vee-next"), is a drop-in replacement for Next.js, built on Vite, that deploys to Cloudflare Workers with a single command. In early benchmarks, it builds production apps up to 4x faster and produces client bundles up to 57% smaller. And we already have customers running it in production.
The whole thing cost about $1,100 in tokens.
The Next.js deployment problem
Next.js is the most popular React framework. Millions of developers use it. It powers a huge chunk of the production web, and for good reason. The developer experience is top-notch.
But Next.js has a deployment problem when used in the broader serverless ecosystem. The tooling is entirely bespoke: Next.js has invested heavily in Turbopack but if you want to deploy it to Cloudflare, Netlify, or AWS Lambda, you have to take that build output and reshape it into something the target platform can actually run.
If you’re thinking: “Isn’t that what OpenNext does?”, you are correct.
That is indeed the problem OpenNext was built to solve. And a lot of engineering effort has gone into OpenNext from multiple providers, including us at Cloudflare. It works, but quickly runs into limitations and becomes a game of whack-a-mole.
Building on top of Next.js output as a foundation has proven to be a difficult and fragile approach. 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.
Next.js has been working on a first-class adapters API, and we've been collaborating with them on it. It's still an early effort but even with adapters, you're still building on the bespoke Turbopack toolchain. And adapters only cover build and deploy. During development, next dev runs exclusively in Node.js with no way to plug in a different runtime. If your application uses platform-specific APIs like Durable Objects, KV, or AI bindings, you can't test that code in dev without workarounds.
Introducing vinext
What if instead of adapting Next.js output, we reimplemented the Next.js API surface on Vite directly? Vite is the build tool used by most of the front-end ecosystem outside of Next.js, powering frameworks like Astro, SvelteKit, Nuxt, and Remix. A clean reimplementation, not merely a wrapper or adapter. We honestly didn't think it would work. But it’s 2026, and the cost of building software has completely changed.
We got a lot further than we expected.
npm install vinext
vinext dev # Development server with HMR vinext build # Production build vinext deploy # Build and deploy to Cloudflare Workers
This is not a wrapper around Next.js and Turbopack output. It's an alternative implementation of the API surface: routing, server rendering, React Server Components, server actions, caching, middleware. All of it built on top of Vite as a plugin. Most importantly Vite output runs on any platform thanks to the Vite Environment API.
Early benchmarks are promising. We compared vinext against Next.js 16 using a shared 33-route App Router application. Both frameworks are doing the same work: compiling, bundling, and preparing server-rendered routes. We disabled TypeScript type checking and ESLint in Next.js's build (Vite doesn't run these during builds), and used force-dynamic so Next.js doesn't spend extra time pre-rendering static routes, which would unfairly slow down its numbers. The goal was to measure only bundler and compilation speed, nothing else. Benchmarks run on GitHub CI on every merge to main.
Production build time:
Next.js 16.1.6 (Turbopack)
vinext (Vite 7 / Rollup)
vinext (Vite 8 / Rolldown)
Client bundle size (gzipped):
vinext (Rollup)
vinext (Rolldown)
These benchmarks measure compilation and bundling speed, not production serving performance. The test fixture is a single 33-route app, not a representative sample of all production applications. We expect these numbers to evolve as three projects continue to develop. The full methodology and historical results are public. Take them as directional, not definitive.
The direction is encouraging, though. Vite's architecture, and especially Rolldown (the Rust-based bundler coming in Vite 8), has structural advantages for build performance that show up clearly here.
Deploying to Cloudflare Workers
vinext is built with Cloudflare Workers as the first deployment target. A single command takes you from source code to a running Worker:
This handles everything: builds the application, auto-generates the Worker configuration, and deploys. Both the App Router and Pages Router work on Workers, with full client-side hydration, interactive components, client-side navigation, React state.
For production caching, vinext includes a Cloudflare KV cache handler that gives you ISR (Incremental Static Regeneration) out of the box:
import { KVCacheHandler } from "vinext/cloudflare"; import { setCacheHandler } from "next/cache"; setCacheHandler(new KVCacheHandler(env.MY_KV_NAMESPACE));
KV is a good default for most applications, but the caching layer is designed to be pluggable. That setCacheHandler call means you can swap in whatever backend makes sense. R2 might be a better fit for apps with large cached payloads or different access patterns. We're also working on improvements to our Cache API that should provide a strong caching layer with less configuration. The goal is flexibility: pick the caching strategy that fits your app.
Live examples running right now:
App Router Playground
Hacker News clone
App Router minimal
Pages Router minimal
We also have a live example of Cloudflare Agents running in a Next.js app, without the need for workarounds like getPlatformProxy, since the entire app now runs in workerd, during both dev and deploy phases. This means being able to use Durable Objects, AI bindings, and every other Cloudflare-specific service without compromise. Have a look here.
Frameworks are a team sport
The current deployment target is Cloudflare Workers, but that's a small part of the picture. Something like 95% of vinext is pure Vite. The routing, the module shims, the SSR pipeline, the RSC integration: none of it is Cloudflare-specific.
Cloudflare is looking to work with other hosting providers about adopting this toolchain for their customers (the lift is minimal — we got a proof-of-concept working on Vercel in less than 30 minutes!). This is an open-source project, and for its long term success, we believe it’s important we work with partners across the ecosystem to ensure ongoing investment. PRs from other platforms are welcome. If you're interested in adding a deployment target, open an issue or reach out.
Status: Experimental
We want to be clear: vinext is experimental. It's not even one week old, and it has not yet been battle-tested with any meaningful traffic at scale. If you're evaluating it for a production application, proceed with appropriate caution.
That said, the test suite is extensive: over 1,700 Vitest tests and 380 Playwright E2E tests, including tests ported directly from the Next.js test suite and OpenNext's Cloudflare conformance suite. We’ve verified it against the Next.js App Router Playground. Coverage sits at 94% of the Next.js 16 API surface. Early results from real-world customers are encouraging. We've been working with National Design Studio, a team that's aiming to modernize every government interface, on one of their beta sites, CIO.gov. They're already running vinext in production, with meaningful improvements in build times and bundle sizes.
The README is honest about what's not supported and won't be, and about known limitations. We want to be upfront rather than overpromise.
What about pre-rendering?
vinext already supports Incremental Static Regeneration (ISR) out of the box. After the first request to any page, it's cached and revalidated in the background, just like Next.js. That part works today.
vinext does not yet support static pre-rendering at build time. In Next.js, pages without dynamic data get rendered during next build
generateStaticParams()
This was an intentional design decision for launch. It's on the roadmap, but if your site is 100% prebuilt HTML with static content, you probably won't see much benefit from vinext today. That said, if one engineer can spend $1,100 in tokens and rebuild Next.js, you can probably spend $10 and migrate to a Vite-based framework designed specifically for static content, like Astro (which also deploys to Cloudflare Workers).
For sites that aren't purely static, though, we think we can do something better than pre-rendering everything at build time.
Introducing Traffic-aware Pre-Rendering
Next.js pre-renders every page listed in generateStaticParams()
So we built Traffic-aware Pre-Rendering (TPR). It's experimental today, and we plan to make it the default once we have more real-world testing behind it.
The idea is simple. Cloudflare is already the reverse proxy for your site. We have your traffic data. We know which pages actually get visited. So instead of pre-rendering everything or pre-rendering nothing, vinext queries Cloudflare's zone analytics at deploy time and pre-renders only the pages that matter.
vinext deploy --experimental-tpr Building... Build complete (4.2s) TPR (experimental): Analyzing traffic for my-store.com (last 24h) TPR: 12,847 unique paths — 184 pages cover 90% of traffic TPR: Pre-rendering 184 pages... TPR: Pre-rendered 184 pages in 8.3s → KV cache Deploying to Cloudflare Workers...
For a site with 100,000 product pages, the power law means 90% of traffic usually goes to 50 to 200 pages. Those get pre-rendered in seconds. Everything else falls back to on-demand SSR and gets cached via ISR after the first request. Every new deploy refreshes the set based on current traffic patterns. Pages that go viral get picked up automatically. All of this works without generateStaticParams()
Taking on the Next.js challenge, but this time with AI
A project like this would normally take a team of engineers months, if not years. Several teams at various companies have attempted it, and the scope is just enormous. We tried once at Cloudflare! Two routers, 33+ module shims, server rendering pipelines, RSC streaming, file-system routing, middleware, caching, static export. There's a reason nobody has pulled it off.
This time we did it in under a week. One engineer (technically engineering manager) directing AI.
The first commit landed on February 13. By the end of that same evening, both the Pages Router and App Router had basic SSR working, along with middleware, server actions, and streaming. By the next afternoon, App Router Playground was rendering 10 of 11 routes. By day three, vinext deploy
What changed from those earlier attempts? AI got better. Way better.
Why this problem is made for AI
Not every project would go this way. This one did because a few things happened to line up at the right time.
Next.js is well-specified. It has extensive documentation, a massive user base, and years of Stack Overflow answers and tutorials. The API surface is all over the training data. When you ask Claude to implement getServerSideProps
Next.js has an elaborate test suite. The Next.js repo contains thousands of E2E tests covering every feature and edge case. We ported tests directly from their suite (you can see the attribution in the code). This gave us a specification we could verify against mechanically.
Vite is an excellent foundation. Vite handles the h
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み