Live data from Hacker News

Next.js is infuriating

blog.meca.sh

561–570 of 602 posts

Re: Next.js is infuriating

#561

Maybe this is a good place to ask... but I was actually considering Next.js as a replacement for Gatsby.js project that is a few years old, but is growing at a steady pace. Given all the negative sentiments, what are better alternatives? I don't even use any SSR, or GraphQL capabilities. The main thing I liked about gatsby vs previous "bring your oown library(router)" are: very little configuring, nice dev server, ea…

We've started a Tanstack Start project at work for a green field project, and it is honestly a mixed bag. It took a lot of trial and error to get the whole project working - the server parts were working without an issue, but there was no client hydration. After some debugging, we have found that there was an error being thrown during data preload which took down the hydration process. No errors were emitted, and the docs weren't were helpful at all.

But once we got that out of the way, it is pretty nice to work with. The FE developer is very happy with how fast the project is and how easy it is to just peek into the BE portion and understand it. Server functions are just so nice to use and everything gels together really well. But it's still early days though. I would only recommend it if you are OK with parsing not-really-great documentation and maybe some relevant GitHub issues from time to time.

Re: Next.js is infuriating

#562

Earlier quoted context omitted.

JavaScript was made insufficiently expressive on purpose (see Eich, Sun, Scheme). He still ended up sneaking some metaprogramming capabilities into it, though he stopped short of something recognizable like macros. So when the highest grade vendors started taking front end extra seriously since I'd say 2008-2010, what they built basically bulldozed over the things that made JS per se tolerable. Instead, they built fr…

Is there a solution? What do you consider the least bad interactive frontend solution?

"Frontend" is literally the integration of Web Platform APIs.

So you need (1) the knowledge of what platform APIs exist (2) the ability to reason about existing abstractions (3) the ability to define abstractions.

In modern life all three are considered unsafe things. Therefore to prevent people from entering invalid states exists The Framework: useless abstraction layer that does nothing besides be conventional. That's a common enough pattern anywhere population's above Dunbar; whether it's embodied by React or TypeScript or Windows or an entirely different order of lowest-common-denominator monoculture is immaterial.

Thankfully, software maintains an objective material component - the code, which they're trying to now turn into another wishy-washy thing you interact with using endless imprecise human language. Purely in terms of that, it remains possible to propose some ways to get a project off the ground more efficiently by virtue of dodging the toxic mainstream:

TL;DR conventional: native DOM manipulation; state management with Observable; Vite; TDD.

TL;DR forward-thinking: same but in proper static language: write in Rust, compile to WASM.

TL;DR exotic: ClojureScript or another Lispy language that compiles to JS or WASM.

Ofc, unless totally cowboying it, you also gotta be able to counteract the illusion of social proof. Ideally you want to be actively shaming people for building and normalizing bloatware. Preferably packing 1-2 yesmen worth of social proof of your own, just to get basic parity with the "best practices" in close quarters.

As always, depends on what you're building, for what purpose, and, critically, with whom... fuck all that though, the objectively bestest solution is always https://github.com/Matt-Esch/virtual-dom /s

That repo is a milestone of where history took its next wrong turn. I remember it making some waves when it dropped, and it's certainly the first VDOM implementation I saw. I considered it a good, original idea.

IIRC, React came around about that time: to take the simple and sane "VDOM" optimization, apply it judiciously (i.e. where it doesn't), and make it possible to bolt enough shit onto it (redux! teaching you to type the same thing thrice before typescript! SAGA! that one weird DB paper from '74 applied to frontends JS' half-baked half-async "generators", just to demonstrate to people that they should revere the old CS publications, and definitely not anything like read them or reason about them!)

Just so that people could hold bloody bootcamps about it, where they'd be able to weed out any junes capable of reading MDN for themselves. ("Bootcamp" is another cosmic joke like "Instagram" and "Trump". That thing where they harass people into obedience then turn them into socially sanctioned murderers? Ok checks out, let's name our programming learning experience! It's nothing if not profoundly mission-driven!)

Back in those days or a little later, I remember Vue 1 and 2 being pretty great: it somehow managed to do its thing without first having to introduce three whole new dialects of JavaScript and counting.

Overall I'm glad to be out of the frontend space for a good while now and only learning about it from the confused screaming of those still trapped there. (Oh and also Next's "static build" is a Docker container I had to cook up myself, which is a next level of ridiculous; as with VDOM, you first need to have seen the past level in order to recognize it as regress, and I presume a lot of people simply haven't had the opportunity to pursue any form of informed comparison)

(For "agentic workflows" idk -- just don't use them ffs the externalities are not remotely priced in; otherwise you'd be the exact same problem as them -- the designed-by-corporate-committee frontend DX of the past decade certainly strike me as something that'd make more sense to a statistical model than to a human mind.)

Re: Next.js is infuriating

#563

Earlier quoted context omitted.

> a relative misunderstanding of exactly where the code is running. This is the exact problem with the App Router. It makes it extremely difficult to figure out where your code is running. The Pages Router didn't have this issue.

Does it? Just look for "use client" at the top of the file.

I love this comment!

"use client" does NOT mean it only renders on the client! The initial render still happens on the server. Additionally, all imports and child components inherit the "use client" directive even when it's not explicitly added in those files. So you definitely cannot just look for "use client".

See what I mean now?

From the docs:

```

On the server, Next.js uses React's APIs to orchestrate rendering. The rendering work is split into chunks, by individual route segments (layouts and pages):

Server Components are rendered into a special data format called the React Server Component Payload (RSC Payload).

Client Components and the RSC Payload are used to prerender HTML.

```

HUH?

```

On the client (first load) Then, on the client:

HTML is used to immediately show a fast non-interactive preview of the route to the user. RSC Payload is used to reconcile the Client and Server Component trees.

```

HUH? What does it mean to reconcile the Client and Server Component trees? How does that affect how I write code or structure my app? No clue.

```

Subsequent Navigations On subsequent navigations:

The RSC Payload is prefetched and cached for instant navigation. Client Components are rendered entirely on the client, without the server-rendered HTML.

```

Ok...something something initial page load is (kind of?) rendered on the server, then some reconciliation (?) happens, then after that it's client rendered...except it's not it actually does prefetching and caching under the hood - surprise.

It's insanely hard to figure out and keep track of what is happening when, and on what machine it's actually happening on.

Re: Next.js is infuriating

#564

Maybe this is a good place to ask... but I was actually considering Next.js as a replacement for Gatsby.js project that is a few years old, but is growing at a steady pace. Given all the negative sentiments, what are better alternatives? I don't even use any SSR, or GraphQL capabilities. The main thing I liked about gatsby vs previous "bring your oown library(router)" are: very little configuring, nice dev server, ea…

We've started a Tanstack Start project at work for a green field project, and it is honestly a mixed bag. It took a lot of trial and error to get the whole project working - the server parts were working without an issue, but there was no client hydration. After some debugging, we have found that there was an error being thrown during data preload which took down the hydration process. No errors were emitted, and the…

Thanks for sharing! :)

Re: Next.js is infuriating

#565
post #80

A lot of companies have Nextjs as a requirement, you can see it in the job posts. It's almost like React = Nextjs, where they don't even mention React. There are developers out there who are highly invested in Vercel's business. Ultimately, the dev teams are responsible for making these decisions. I've encountered issues based on Nextjs in a few projects where the best approach was to eliminate it. The outcome was ni…

I talked to a computer science student who told me that React is old, no one is using that anymore. He said now NextJS is the thing to use. No matter how hard I tried to explain to him that NextJS is a framework that uses React, he would not listen or understand. Scary times ahead.

NextJS is web-scale.

Re: Next.js is infuriating

#566

Earlier quoted context omitted.

Is there a solution? What do you consider the least bad interactive frontend solution?

"Frontend" is literally the integration of Web Platform APIs. So you need (1) the knowledge of what platform APIs exist (2) the ability to reason about existing abstractions (3) the ability to define abstractions. In modern life all three are considered unsafe things. Therefore to prevent people from entering invalid states exists The Framework: useless abstraction layer that does nothing besides be conventional . Th…

Hahaha. What post. Forgot to add (!): that I have finally transcended the agony of the frontend space, does not mean a facet of my spirit does not perpetually lurk on that threshold in half-mockery, half-still-agony. (After all, cognitive science is yet to make a pronouncement as to whether it is possible to forget TypeScript.)

Do you want to be a spirit haunting the threshold in half-agony, half-but-also-mockery? It's accomplished by the "Figuring Out How NPM Packaging Actually Works So You Can Write Proper Isomorphic Business Logic" ritual, a fell rite from the forbidden "Uncomfortable Truths About The Presentation Layer" grimoire, and one that a lot of them would be better off with you not knowing, and now you do ;-)

Re: Next.js is infuriating

#567

Earlier quoted context omitted.

Sounds like Javascript's answer to Spring.

Java Spring is at root a way to combine large software components (singletons) together in a controlled manner (dependency injection). It doesn't really have an opinion on what you do with it, or even if you use it for webapps. In fairness the Servlet API (which predates Spring) was and always has been really good (which is why it's still the foundation of everything webapp in the Java ecosystem). Oddly enough, loggi…

Spring Boot pulls in countless dependencies without warning. It can generate classes without you asking it to. It will run code just because you added a dependency, even if you don't explicitly call it. A lot of functionality is action-at-a-distance activated through annotations, which could just as easily be simple method calls which are easier to trace and debug. Version updates are aggressive about making breaking changes, sometimes seemingly for aesthetic reasons.

It just adds a lot of complexity even if you don't explicitly opt in to it or need it.

Re: Next.js is infuriating

#568

Earlier quoted context omitted.

Seems more like a test on random React minutiae. Like, let's take some framework, take away some random piece. How well do you know the area around that random piece we just removed? Frameworks are large and gnarly (or there isn't enough to them). Expecting a candidate to be lucky and know random implementation details in the area that happened to be picked doesn't seem like you'd select for anything other than luck.…

It's not React "minutiae". It's incredibly basic concepts, that if you don't know, you cannot in good faith say you know react. It's like not knowing how to write a for loop or how to access an object's property in JavaScript.

I remember one of the first technical interviews I conducted about 15 years ago, I asked the candidate the difference between == and ===. She had the same answer as gp, claiming the doesn't "memorize minutiae like that."

Re: Next.js is infuriating

#569

Earlier quoted context omitted.

Does it? Just look for "use client" at the top of the file.

I love this comment! "use client" does NOT mean it only renders on the client! The initial render still happens on the server . Additionally, all imports and child components inherit the "use client" directive even when it's not explicitly added in those files. So you definitely cannot just look for "use client". See what I mean now? From the docs: ``` On the server, Next.js uses React's APIs to orchestrate rendering…

Correct, 'use client' means it can render in the browser, not that it only renders there. Rendering only in the browser would break SSR.

If you try to use browser functionality in a component without 'use client' or to use server functionality in a client component, you'll get an error.

Re: Next.js is infuriating

#570

I 100% agree. I've ran into the same issues, and I would never use Next.js for anything, and I will encourage every team at work to use something else. In general Next.js has so many layers of abstraction that 99.9999% of projects don't need. And the ones that do are probably better off building a bespoke solution from lower level parts. Next.js is easily the worst technology I've ever used.

My biggest problem with it now is the official React team pushes it as their framework of choice. Back when it used the Pages Router and wasn't trying to push everything into server components, etc., it wasn't terrible but I can't help but feel bad for any newcomers trying to learn web development. I switched to Astro from Next for most projects and haven't looked back. It's such a breath of fresh air to use.

Next.js was a godsend when it came out because of how easy it made SSR. Many React projects don't need SSR, but for those that do it was technically complicated and time-consuming to hand-roll it.

I was part of a successful large project where we did our own SSR implementation, and we were always tinkering with it. It wasted a lot of time. Next.js "just worked". I've used Next with the pages router on two significant and complex projects and it was a great choice. I have no regrets choosing it.

Post reply on HN