logoalt Hacker News

How we rebuilt Next.js with AI in one week

417 pointsby ghostwriternryesterday at 8:07 PM162 commentsview on HN

Comments

hungryhobbityesterday at 10:07 PM

Man, I love Next ... but I also love Vite ... and I hate the Next team, because they focus on fancy new features for 0.1% of their users, at the complete expense of the other 99.9% of the Next community (who they basically ignore).

This gives someone like me everything we want. Better performance is something the Next community has been begging for for years: the Next team ignored them, but not the Cloudflare team. Meanwhile Vite is a better core layer than the garbage the Next people use, but you still get the full Next functionality.

I wish Cloudflare the best of luck with this fork: I hope it succeeds and gets proven so I can use it at my company!

show 9 replies
switzyesterday at 8:58 PM

This is pretty fascinating and comes with some complicated AI-world incentives that I've been ruminating on lately. The better you document your work, the stronger contracts you define, the easier it is for someone to clone your work. I wouldn't be surprised if we end up seeing open source commercial work bend towards the SQLite model (open core, private tests). There's no way Cloudflare could have pulled this off without next's very own tests.

Speaking more about the framework itself, the only real conclusion I have here is that I feel server components are a misunderstood and under-utilized pattern and anyone attempting to simplify their DX is a win in my book.

Next is very complex, largely because it has incrementally grown and kept somewhat backwards compatible. A framework that starts from the current API surface and grows can be more malleable and make some tough decisions here at the outset.

Crazy to see it's already being run on a .gov domain[0]. TTFGOV as a new adoption metric?

[0] https://www.cio.gov/

show 4 replies
wesselbindttoday at 12:16 AM

I wonder to what extent you should say you "rebuilt" something when the most basic hello world example doesn't work. And I wonder to what extent it makes sense to call it "from scratch" if you inherit a battle tested extensive test suite from the thing you're rebuilding, and the thing you're rebuilding is part of the training data.

Here's the first paragraph of Harry Potter and the philosopher's stone. I rewrote it from scratch, apparently:

Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much. They were the last people you’d expect to be involved in anything strange or mysterious, because they just didn’t hold with such nonsense. Mr. Dursley was the director of a firm called Grunnings, which made drills. He was a big, beefy man with hardly any neck, although he did have a very large mustache.

ratorxyesterday at 10:25 PM

I find it interesting that they bought Astro (https://blog.cloudflare.com/astro-joins-cloudflare/), which from my definitely-not-a-frontend-person perspective seems to tackle a similar problem to Next. A month ago.

If it is so cheap to make something that they recommend using (rather than a proof of concept), why buy Astro (presumably it was more expensive than the token cost of this clone?).

One conclusion is that, at the organisational level, it still makes sense to hire the “vision” behind the framework, rather than just clone it. Alternatively, maybe AI has improved that much in 1 month!

show 8 replies
thawabyesterday at 9:56 PM

Nextjs had remote code execution vulnerabilities because of how they implemented react server side. I am not touching an AI version without waiting for a while.

show 2 replies
wewewedxfgdfyesterday at 11:23 PM

I'm deeply skeptical of the "X reimplemented and it was super easy" thing.

The devil is in the detail.

So many edge cases unlikely to be there.

So many details or fine details unlikely to be there.

Years of bug fixes.

If it is literally a drop in replacement and it passes all the tests, and you're replicating something with and extremely thorough test suite, then sure I'll give you the benefit of the doubt.

Otherwise, I don't believe people "rebuilt X product in a week".

show 1 reply
slopinthebagyesterday at 11:02 PM

This is probably the most interesting AI experiment I've seen yet. Looking through the codebase has me wondering where all the code is. I don't know if anyone has had the displeasure of going through the next.js codebase, but I estimate it's at least two orders of magnitude more code than this reimplementation. Which makes me wonder, does it actually handle the edge cases or does it just pass the tests.

Like compare the two form implementations for example. Vinext is a completely different implementation compared to what the Next.js version does. Is their behaviour actually the same? The rewrite looks incredibly naive.

https://github.com/vercel/next.js/blob/b8cbaad24ca66ec673a7b...

https://github.com/cloudflare/vinext/blob/main/packages/vine...

Either way, pretty impressive.

show 3 replies
theteapotyesterday at 10:59 PM

> Most abstractions in software exist because humans need help. We couldn't hold the whole system in our heads, so we built layers to manage the complexity for us.

Kind of a sloppy statement, but I don't think it's accurate to say abstraction or layering exists in software just because humans need help comprehending it. Abstractions often exist to capture the essence of some aspect of the real world, and to allow for software reuse. AIs will still find reusing software useful? Secondly, you equate "abstractions" with "layers" which aren't really the same thing. Layers are more about separation of concerns. Maybe it could be argued layering is a type of abstraction.

hackersktoday at 2:41 AM

The buried lede here is the Astro acquisition timing. Cloudflare bought Astro a month ago, and now they're showing they can replicate Next.js's API surface with AI in a week. The strategic play isn't vinext itself — it's signaling to the market that framework lock-in is dissolving.

If you're a Next.js shop stuck on Vercel because self-hosting is painful, Cloudflare just gave you two exit ramps: Astro (for new projects) and vinext (for existing ones). Whether vinext is production-ready today matters less than what it represents for Vercel's pricing power.

The real question nobody's asking: if your framework's value can be replicated by targeting its test suite, what exactly are you paying for with Vercel's premium tiers? The answer used to be "the only place Next.js runs well." That moat is eroding fast.

show 3 replies
rc1yesterday at 9:42 PM

> The whole thing cost about $1,100 in tokens.

I like this is called out.

htchyesterday at 8:28 PM

In hindsight, a totally expected achievement given where models are and the high quality tests available, but wildly impressive all the same.

I don’t know what this means but it feels like yet another milestone moment.

dsmmckentoday at 12:04 AM

fwiw, I just tried running the agent-skill they provide for fun to migrate an app-router based next 15 site and the end result is it entirely failed to start.

Vite just hangs when running vinext dev, with no output in logs whatsoever beyond printing`vinext dev (Vite 7.3.1)`.

cline6yesterday at 11:03 PM

The article say that "Next.js is well-specified." I... don't think this is actually true. It certainly has lots of documentation, but as has come up time and time again, there are tons of undocumented or poorly documented behaviors that have been the cause of consternation.

So I kinda wonder, did they just create the framework that Next.js claims to be but never has been? And is Next.js without the hidden stuff actually a good framework? Who knows.

bryanrasmussenyesterday at 9:49 PM

someone spent over 1000 dollars to replicate the functionality of Next.JS, even 1 dollar would seem too much somehow. I suppose that is me being overly retributive.

show 1 reply
keeganpoppenyesterday at 10:08 PM

i love how this disintermediates the next.js/vercel axis, which seems to be determined to make basically everything hard except for exactly what they want to do. as much as i love what vercel has done for open source in general (amazing stuff!) it is hard to interpret some of the stuff they do with next as anything other than vendor lock-in bs… the kind that i know is not in their hearts.

aggregator-iosyesterday at 9:45 PM

[flagged]

show 9 replies
srameshctoday at 2:28 AM

I love Cloudflare but not a big fan of Next, I love Remix though :) But getting to make things work on Cloudflare is a pain, hopefully they will make it easier with OpenNext. On the other hand , maybe they can do something better at infrastrucute level , rather than make it easier, like a lot easier to bring your own JS flavor.

aplomb1026today at 12:32 AM

The most underappreciated insight here is that the test suite turned out to be more valuable than the source code itself. 2k unit tests + 400 E2E tests effectively served as a machine-readable specification that an LLM could target. This inverts the traditional open source value proposition: previously, the code was the asset and tests were the safety net. Now the tests are the asset and the code is replaceable. Expect frameworks to start treating their test suites as proprietary even if the source stays open.

show 1 reply
vivzkestreltoday at 3:24 AM

- since you guys are experimenting that much, i have a favor to ask

- could you rewrite next and react actually without using a virtual dom at all and use a compiler like svelte instead?

syrusakbarytoday at 2:49 AM

This is amazing. At Wasmer we are a bit concerned of Next.js and this replacement might come in handy!

I actually was thinking on creating something similar. Congrats to the Cloudflare team

samtheprogramyesterday at 11:23 PM

The irony of this in the README:

- Node.js production server (vinext start) works for testing but is less complete than Workers deployment. Cloudflare Workers is the primary target.

handbanana_today at 3:35 AM

I am so over reinventing the wheel in tech, I feel as if that's 99% of where the money and time goes

jtbakeryesterday at 10:23 PM

All my homies hate Next.js

show 1 reply
troupoyesterday at 9:57 PM

Here's what is buried a bit in the text:

--- start quote ---

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.

--- end quote ---

The real achievement is human-built Vite (and it is an amazing project).

Since Next.js's API surface and capabilities are known, this is actually quite a good use of AI: re-implement some functionality using a different framework/language/approach. They work rather well with that.

show 1 reply
rileymichaelyesterday at 11:21 PM

...and (again), hello world does not work [1]. the ai slop pr [2] absolutely butchers the fix. anyone foolish enough to switch to this is in for a rough time. details matter!

[1] https://github.com/cloudflare/vinext/issues/22

[2] https://github.com/cloudflare/vinext/pull/31/changes#r284987...

adithyassekhartoday at 1:39 AM

> We also want to acknowledge the Next.js team. They've spent years building a framework that raised the bar for what React development could look like. The fact that their API surface is so well-documented and their test suite so comprehensive is a big part of what made this project possible.

Hi next.js devs, we like to acknowledge the effort you put for writing good tests so we were able to rip it off. You know claude already has next's entire source code in it's training data?

show 1 reply
tills13yesterday at 11:34 PM

I get the gist here but I hate the tone of these sorts of posts. Imagine being a NextJS developer, pouring your heart and soul into it day after day, knowing the codebase inside and out, and seeing some dude on the Cloudflare blog bragging about how he rewrote your project in a week using AI. It's tone deaf. It's not impressive.

The tool is hella useful. The messaging is ignorant. This should have been a "we built a tool to deploy NextJS on cloudflare natively" instead of this AI brag.

show 2 replies
vercantezyesterday at 9:57 PM

Great to see. Could have use this last month when we migrated from OpenNext on CF to React Router 7

efilifetoday at 1:34 AM

This tells me everything about recent cloudflare outages

freakynittoday at 2:42 AM

THIS IS THE WAY.

Human in the loop, acting as an orchestrator.

evilhackerdudeyesterday at 10:16 PM

> The [next.js] developer experience is top-notch.

let me add my own unqualified statement to that: no.

> 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.

it's almost as if vercel had some kind of financial incentive to gear this towards their own platform.

> reimplemented the Next.js API surface on Vite directly

a clown car screeches to a halt; several burnt-out-bored oracle vs google lawyers climb out and, weirdly, i am there for it

all in all, it's definitely a good example of something we couldn't have done for $1100 pre-llms, but: should we have? did somebody consult the lava lamps?

jcuenodtoday at 12:20 AM

Just you wait, I will post how I rebuilt cloudflare with AI in one week

show 1 reply
jdthediscipleyesterday at 9:43 PM

Shots fired, Vercel folks better hide!

moffkalastyesterday at 11:12 PM

> 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.

Wouldn't be like Claude to maybe forget to implement half the library, would it?

I guess they can call themselves Claudeflare now ;)

dmixtoday at 12:05 AM

What the status on Vite Rolldown? Is it nearing production?

csomartoday at 1:25 AM

I have done a similar thing with my web app (codeinput.com) and honestly wouldn’t touch this thing for even a fun project. My reason to migrate was two fold: nextjs simply didn’t work with Cloudflare workers and IBM carbon required ‘use client’ for every page which meant that no HTML was generated. Everything was client side.

Google Gemini, at the time, created an SSG solution which I had spent the next 3-4 months fixing bugs for. Consequently, I had to understand the whole SSG build step and all the wrong design decisions the AI made that resulted in the site getting a horrible core web vitals score. In the end, I just put the site behind a white “div” that disappear when the page finally loads. SSR is way more complex than it sounds.

This project (along with the quantum post) is quite concerning. It’s not clear why Cloudflare has decided to take this direction. If you want to know why LLMs are completely unable to produce something even close to NextJS, a better solution would have been to ask the LLM to fix the opennext adapter rather than building a new framework from scratch.

tgman12today at 12:03 AM

The result of these heists is that no one will publish test suites on the Internet in the future.

The tone of the blog post is upbeat. What are the consequences? Is the new performance expectation at Clownflare to "port" one framework per week? Do you have to generate at least 20 kLOC per week? Aren't you redundant right now?

missing_cipheryesterday at 11:15 PM

Traffic-aware Pre-Rendering is smart

2001zhaozhaoyesterday at 10:23 PM

This is another example that good tests (e.g. Next.js's own test suite) are SO incredibly important to making the AI able to work on big projects autonomously with lower steering. So is a very domain-knowledgeable human in charge of steering.

kundiyesterday at 10:35 PM

Next-js team is a bunch of inexperienced teens who like good looking UIs and their lousy platform to upsell their services. Very glad to see this

redwoodyesterday at 10:50 PM

I would not want to be working on Cloudflare's Vercel partner team about now.. talking about a diplomacy-forward role

fullstackchristoday at 2:22 AM

Lots of hate for NextJS in here so im wondering what people use as an alternative framework...

Gatsby? I used to use that one until the updates basically ceased to exist.

Vite with <insert your favorite here> - looks good, but at initial glance seems to favor just pure speed for any other feature support like MDX, advanced SEO, etc.

Roll your own with React and webpack? Good luck, and you'll probably end up with something that looks like the others I've mentioned above.

Just surprised many comments are just stating complaints about Next and not providing any counter examples, its very un-HN.

verdvermyesterday at 8:50 PM

NextJS is bad enough, cannot imagine an Ai version

Cloudflare also lost my support because their support is among the worst, rep evn sneered (cannot update my WHOIS, still, after months of emails). Strongly recommend avoiding their platform. You will find that you lose more time & money to dealing with the issue of parity. God help you if you ever need support, almost every question in Discord goes unanswered as well.

show 1 reply
uthal100yesterday at 11:25 PM

The most obnoxious man in the middle of the Internet rips off other people's code. Who knew?

Does anyone have experiences with the EU alternative bunny.net?

show 1 reply
carverautoyesterday at 10:33 PM

good job, now you have to support that mess that took 3774~ contributors to build.

have fun.

show 2 replies
eaf7e281yesterday at 10:38 PM

again?

acedTrexyesterday at 10:01 PM

God cloudflare's blog quality has fallen off a fuckin cliff ehh. Used to be so good now its just llm slop both content and actual writing.

show 4 replies
MarcLoretoday at 2:01 AM

[dead]

🔗 View 2 more comments