News for hackers. Stuff that matters.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by qudat on Saturday May 03, 2025 @03:49PM (#43881630)
Having a server provide an island or rendering framework for your site can be more complex than an SPA with static assets and nginx.

You still have to deal with all the tooling you are talking about, right? You’ve just moved the goalpost to the BE.

And just like the specific use cases you mentioned for client routing I can also argue that many sites don’t care about SEO or first paint so those are non features.

So honestly I would argue for SPA over a server framework as it can dramatically reduce complexity. I think this is especially true when you must have an API because of multiple clients.

I think the DX is significantly better as well with fast reload where I don’t have to reload the page to see my changes.

People are jumping into nextjs because react is pushing it hard even tho it’s a worse product and questionable motives.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by freeone3000 on Saturday May 03, 2025 @03:59PM (#43881743)
But on the flip side, you can program the backend in anything you like, instead of being bound to javascript.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by sroussey on Saturday May 03, 2025 @04:29PM (#43882012)
JS/TS is fine. Why switch back and forth between languages and frameworks and data models and…
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by baq on Saturday May 03, 2025 @05:26PM (#43882458)
If your axiom is ‘JS is fine’ then yeah. It isn’t, though. TS is much closer to ‘fine’, but still can’t avoid some dumb JS decisions.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by CuriouslyC on Saturday May 03, 2025 @07:46PM (#43883283)
I've been a professional programmer for ~20 years and worked in a variety of languages on a variety of different types of projects, and Typescript with Bun is mostly just fine. It lacks some low level primitives I'd like to have available for certain projects (e.g. Go channels), and the FFI interface isn't as nice as I'd like, but it's basically serviceable for for a very broad range of problems.

You should still know a language like Rust or Zig for systems work, and if you want to work in ML or data management you probably can't escape Python, but Typescript with Bun provides a really compelling development experience for most stuff outside that.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by baq on Sunday May 04, 2025 @05:24AM (#43885592)
I agree, nowadays working on mostly TS backend with some parts in JS written before async/await was introduced and I’m inclined to say TS is better than Python at most things bakcendy. I’m missing sqlalchemy and a sane numerical tower pretty much.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by freeone3000 on Sunday May 04, 2025 @03:46PM (#43889022)
Python suffers from the same problems: its type system has many escapes and implicit conversions, making soundness opt-in and impossible to statically verify. Any language with an implicit cast from its bottom type to an upper type is unsuitable for use.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by AlchemistCamp on Sunday May 04, 2025 @01:53PM (#43888220)
It reminds me of an older dev I met when I was just beginning who had worked even more years and said Fortran 95 was "fine". And he could use it to build pretty much anything. That doesn't mean that more powerful language features couldn't have increased his productivity (if he learned them).
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by CuriouslyC on Sunday May 04, 2025 @05:36PM (#43889786)
There's something to be said for using the right tool for the job. There's also something to be said for maximizing your ability to hire developers. Software is a game of tradeoffs, and while I can and do still pick up modern hotness when warranted (e.g. Zig), sometimes the path to minimum total software cost (and thus maximum company value) is to take well trodden paths.

As fun side anecdote, if you're doing scientific computing in a variety of fields, Fortran 95 is mostly still fine ;)

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by chipsrafferty on Saturday May 03, 2025 @05:57PM (#43882680)
It is fine, though.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Saturday May 03, 2025 @06:34PM (#43882927)
No, it’s footgunny and riddled with bugs. Most JS barely works and edge cases just aren’t addressed.

I’ve seen undefined make it all the way to the backend and get persisted in the DB. As a string.

JS as a language just isn’t robust enough and it requires a level of defensive programming that’s inconvenient at best and a productivity sink at worst. Much like C++, it’s doable, but things are bound to slip through the cracks. I would actually say overall C++ is much more reasonable.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by Capricorn2481 on Sunday May 04, 2025 @11:55AM (#43887456)
> I would actually say overall C++ is much more reasonable.

This is where I know that, some people, are not actually programming in either of these languages, but just writing meme driven posts.

JS has a few footguns. Certainly not so many that it's difficult to keep in your head, and not nearly as complex as C++, which is a laughable statement.

You've "seen null make it to the database," but haven't seen the exact same thing in C++? Worse, seen a corrupted heap?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hombre_fatal on Sunday May 04, 2025 @12:24PM (#43887625)
Yeah, I don't know how someone can say that with a straight face to other engineers.

It's like people just talk in memes or something.

This is how a lot of discourse feels these days. People living in very different realities.

Though in this case, seeing the most complex C++ app they've built would illuminate what's going on in theirs.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Sunday May 04, 2025 @02:12PM (#43888341)
It's not a different reality. To give perspective to what JS I've dealt with - I worked a couple years on a legacy webapp. It used vanilla JS and the only library used was jQuery. It heavily used iframes for async functionality in combination with XSLT to translate backend XML apis to HTML.

Opening up a 10K lines JS file is like jumping into the ocean. Nothing is obvious, nothing makes sense. You're allowed to just do whatever the fuck in JS. Bugs where always ephemeral. The behavior of the code was impossible to wrap your head around, and it seemed to change under your feet when you weren't looking.

Now, the backend was written in old C++. And yes, it was easier to understand. At least, I could click and go to definition. At least, I could see what was going in and out of functions. At least, I could read a function and have a decent understanding of what it should be doing, what the author's intention is.

The front end, spread across a good thousand JS files, was nothing of the sort. And it was certainly more buggy. Although, I will concede, bugs in C++ are usually more problematic. In JS usually it would just result in UI jankyness. But not always.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by sroussey on Monday May 05, 2025 @11:35AM (#43896211)
> You're allowed to just do whatever the fuck in JS.

I think that’s a feature not a bug.

But then again, I generally like and use Typescript.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Monday May 05, 2025 @02:50PM (#43898175)
It's definitely a feature when you're starting out. But as the codebase grows and ages, it becomes a bug.

The problem is that the behavior becomes so complex and so much is pushed to runtime that there's no way to know what the code is actually doing. There's paths that are only going to be executed once a year, but you don't know which ones those are. Eventually, editing the code becomes very risky.

At this particular codebase, it was not uncommon to see 3, 4 or 5 functions that do more or less the same thing. Why? Because nobody dared change the behavior of a function, even if it's buggy. Maybe those bugs are the only thing keeping other bugs from cropping up. It's like wack-a-mole. You fix something, and then the downstream effects are completely unpredictable.

It becomes a self-eating snake. Because the codebase is so poor, it ends up growing faster and faster as developers become more risk-averse.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by Capricorn2481 on Tuesday May 06, 2025 @03:46PM (#43908904)
> The problem is that the behavior becomes so complex and so much is pushed to runtime that there's no way to know what the code is actually doing. There's paths that are only going to be executed once a year, but you don't know which ones those are. Eventually, editing the code becomes very risky.

It's clear you've worked on a really bad codebase, but this is totally different from what you were originally suggesting, which was null being a bigger problem in JS than C++.

What you're describing is frontend development with JQuery, not the capabilities of JS. Now, I don't like NextJS for a lot of reasons, but code organization is not one of them. Everything you're complaining about is dead simple in NextJS. Functions are localized, tracking localized state is easy, and even the older React state libraries have lots of support for tracking and visualizing the more global state changes.

I will die on the hill that JQuery, outside of very small interactivity, is fucking bad. People use JQuery terribly and it creates spaghetti code where you can't tell what the execution path is. People don't document QA testing. And JQuery makes you target html attributes to make changes. That's fun if you have to do it once, it's terrible if all of your app interactivity relies on it.

But that's not due to "undefined", and it would be 100x worse in C++. I am assuming the C++ codebase you compared it to was not a DOM manipulating app?

I don't like NextJS for performance and market reasons, but the codebases I've worked on have been very clean.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Wednesday May 07, 2025 @10:08PM (#43922448)
IMO jQuery is a symptom, not a cause. It’s the natural end-state of a stringly-typed “do whatever the fuck you want” attitude. You can create just as much spaghetti without jQuery, jQuery just lets you do it with less characters.

The horrors I’ve seen. Constructing a custom string based off of user input and then tacking on () and calling it as a function? We can do that? Apparently yes we can. The most cursed type of polymorphism where nothing makes sense and you’d have more success communing with the dead than deducing the control flow.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Sunday May 04, 2025 @02:07PM (#43888317)
I haven't seen null make it to the database, I've seen undefined. And here you demonstrate one of many problems - there's multiple null types!

In C++, there's only one null, nullptr. But most types can never be null. This is actually one area where C++ was ahead of the competition. C# and Java are just now undoing their "everything is nullable" mistakes. JS has that same mistake, but twice.

It's not about complexity, although that matters too. C++ is certainly more complex, I agree, but that doesn't make it a more footgunny language. It's far too easy to make mistakes in JS and propagate them out. It's slightly harder to make mistakes in C++, if you can believe it. From my experience.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by neonsunset on Sunday May 04, 2025 @02:45PM (#43888566)
C# introduced nullable reference types back in 2019, so it's been some time and now the vast majority of the ecosystem uses null-aware code. The only remaining warts are around a. codebases which refuse to adopt this / opt out of it and b. serialization.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by Capricorn2481 on Tuesday May 06, 2025 @03:29PM (#43908758)
I am really trying to get on board, but I don't know what you mean. I see your anecdote about two different codebases and you found the C++ one easier, and I'm sure it happens.

> And here you demonstrate one of many problems - there's multiple null types

In JS, null and undefined are not meaningfully different unless you're checking for exactly one or the other. And there's little reason to do that. It has never come up for me that undefined made it through where null wouldn't have. But yes, you need to check if things are defined.

> In C++, there's only one null, nullptr. But most types can never be null

C++ absolutely has undefined, it just doesn't tell you about it. If I make a var with `int myVar;` it's undefined. There's no telling what it points to. But C++ will treat it as `int`. And it can be a lot worse. Vars can be memory represented as the wrong type. They can be truncated memory, dangling pointers, memory freed twice.

But with JS, if I access memory that wasn't explicitly set, it says "that's undefined." That's a good and explicit thing to tell me, and I can actually check for it. And the GC, obviously, avoids a whole class of cases where undefined would come up.

> This is actually one area where C++ was ahead of the competition

For the reasons above, I would say C++ is literally the worst option for null safety. Unless we define safety as "don't tell me this is undefined, even though it is."

> It's far too easy to make mistakes in JS and propagate them out

I'm just not sure why. I would say C++ has absolutely every footgun JS has and more.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Wednesday May 07, 2025 @10:04PM (#43922426)
C++ is at least somewhat strictly typed and - again - most types cannot be null.

Make std::string null. You can’t. Make std::vector null. You can’t. It’s one of the benefits of a value types.

That, alone, eliminates a whole class of bugs that’s JS has. Yes, there’s edge cases in C++ too. The edge cases are the common cases in JS in this regard and that’s why I class them differently. Really, every language can do everything, basically. But how easy is it, and how common is it?

Also, for the record, using an initialized variable will result in a warning or compilation error.

None of this is to say that C++ does not have other glaring problems that JS does not. But, in my experience, it’s slightly more difficult to create logic bugs in C++. I also have worked with PHP - similar situation to JS. Too footgunny that in practice the codebase is riddled with bugs that rarely manifest, but are there. Everything you do has, like, a dozen implications and edge cases you need to consider.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by sroussey on Monday May 05, 2025 @11:39AM (#43896248)
You really need to learn a language to use it. As for undefined vs null, I fine it useful. Particularly in a db setting. Was the returned value null? You know because the value is null. Did you actually load it from the database? sure, because the value is not undefined.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hjgjhyuhy on Saturday May 03, 2025 @09:21PM (#43883719)
If you already know another backend language and framework, all you need to do is tell LLM or some code generator to convert your models between languages. There is very little overhead that way.

I greatly prefer Java with Spring Boot for larger backend projects.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by aweiland on Saturday May 03, 2025 @09:56PM (#43883864)
What is 0.1 + 0.2 in JavaScript. I'll give you a hint, it's not 0.3. Is that fine?
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by viraptor on Saturday May 03, 2025 @10:39PM (#43884056)
That's not a JavaScript issue. It's the same for almost any language where you don't use some bignum type/library. This is something all developers should be extremely aware of.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by baq on Sunday May 04, 2025 @05:27AM (#43885605)
https://en.m.wikipedia.org/wiki/IEEE_754

To answer your question directly - yes, it’s fine, it’s actually expected behavior.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by SJC_Hacker on Saturday May 03, 2025 @05:14PM (#43882380)
You haven’t had to deal directly with JS on front end since Dart released over 10 years ago
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by freeone3000 on Saturday May 03, 2025 @08:26PM (#43883486)
Dart hasn’t been much better in my experience, but you have reminded me to revisit Kotlin/JS!
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by freeone3000 on Monday May 05, 2025 @10:48AM (#43895709)
I tried getting json deserialization into my app and ended up with a 2MB runtime, so it’s not going great.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by catgirlinspace on Saturday May 03, 2025 @08:42PM (#43883561)
Does anyone use Dart without Flutter? I've never seen it used separately.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by SJC_Hacker on Sunday May 04, 2025 @01:47PM (#43888179)
Yeah sorry I meant Flutter ... 99% of people use Dart with Flutter, they are basically synonymous
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by yawaramin on Friday May 09, 2025 @03:33PM (#43940233)
No, you still need to deal directly with JS even with a transpiler like Dart or whatever other language you want to use. When things go wrong, and they will, you'll need to deal with the JS errors. When you're trying to debug or even call out to JS APIs, you better be intimately familiar with how your transpiler interops with JS, otherwise you're kinda screwed.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by stavros on Saturday May 03, 2025 @04:23PM (#43881949)
I disagree, the problem with an SPA is that now you have two places where you manage state (the backend and the frontend). That gives you much more opportunity for the two places to disagree, and now you have bugs.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by procaryote on Saturday May 03, 2025 @04:33PM (#43882052)
You had to manage state on the frontend even before spa though, if you wanted anything but the most basic experience.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Saturday May 03, 2025 @06:30PM (#43882907)
No you really don’t. I’ve worked on exceptionally complex legacy applications with essentially no state in the front end. At most, you’re looking at query parameters. You just make everything a full page reload and you’re good to go.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by balencpp on Sunday May 04, 2025 @03:52AM (#43885248)
So you make incrementing a counter a full page reload?
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by phoronixrly on Sunday May 04, 2025 @08:43AM (#43886395)
Let's be honest -- the alternative is an API call with poor or no error-handling with the brilliant UX of either hanging with an endless loading indicator, or just flat out lying that the counter was incremented...
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ziml77 on Sunday May 04, 2025 @12:35PM (#43887703)
> or just flat out lying that the counter was incremented...

Which is what HN does and it sucks. It's very common for me to vote on a couple things and then after navigating around I come back to see that there are comments that don't have a vote assigned.

Of course the non-JS version would be even more annoying. I would never click those vote buttons if every vote caused a full page refresh.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ysavir on Sunday May 04, 2025 @10:26AM (#43886905)
You don't need an SPA to handle incrementing a counter. If a page needs dynamic behavior you add JS to it, whether it's just adding an in-memory counter or an API call to store and retrieve some data. It's not difficult to write JavaScript.

The problem with SPAs is that they force having to maintain a JS-driven system on every single page, even those that don't have dynamic behavior.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by Capricorn2481 on Sunday May 04, 2025 @11:48AM (#43887414)
That's still state on the frontend, which the commenter claimed sites don't need.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ysavir on Sunday May 04, 2025 @01:52PM (#43888213)
True, I shouldn't have said in memory. As the GP mentioned, you can store the counter value in a URL param. There are ways to achieve dynamic behavior without having to load or store values into JS memory.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by procaryote on Monday May 05, 2025 @04:32AM (#43892972)
That is more work both for the developers and the servers though. You need to re-render the whole page every change, rather than make a local change (or a tiny request if it needs to persist)
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ysavir on Monday May 05, 2025 @06:55AM (#43893645)
You misunderstood what I was saying. I was saying that you could write some plain old JS to catch an event on incrementing and updated the URL and the UI, and some JS to get the data from the URL on page load to set the UI. No new server render, and that's maybe 5 minutes of writing JavaScript code (compared to, say, setting up react project and instantiating that whole beast from the page root until reaching the specific UI element that needs to be dynamic).
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Sunday May 04, 2025 @04:59PM (#43889526)
> You don't need an SPA to handle incrementing a counter. If a page needs dynamic behavior you add JS to it, whether it's just adding an in-memory counter or an API call to store and retrieve some data. It's not difficult to write JavaScript.

I agree with this. Sprinkle in the JS as and when it is needed.

> The problem with SPAs is that they force having to maintain a JS-driven system on every single page, even those that don't have dynamic behavior.

I don't agree with this: SPAs don't force "... having to maintain a JS-driven system on every single page..."

SPA frameworks do.

I think it's possible to do reasonably simple SPAs without a written-completely-in-JSX-with-Typescript-and-a-5-step-build-process-that-won't-work-without-25-npm-dependencies.

I'm currently trying out a front-end mechanism to go with my high-velocity back-end mechanism. I think I've got a good story sorted out, but it's early days and while I have used my exploratory prototype in production, I've only recently iterated it into a tiny and neat process that has no build-step, no npm, and no JS requirement for the page author. All it uses is `<script src=...>` in the `<head>`, with no more JS on the rest of the page.

Very limited though, but it's still early days.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ysavir on Sunday May 04, 2025 @05:31PM (#43889759)
A codebase doesn't need that toolset to be an SPA. An SPA is just a website where all the site's functionality is done on the "root page", and it uses JS to load the data, handle navigation, etc. Doesn't matter whether that's all done through React in TypeScript and compiled by Vite or by handrolled JavaScript fetched in .js files.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Sunday May 04, 2025 @05:56PM (#43889926)
> A codebase doesn't need that toolset to be an SPA.

That's kinda the goal I'm trying to reach. If you know of any SPA that doesn't come with all the baggage and only uses `<script src=...>`, by all means let me know.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Sunday May 04, 2025 @02:15PM (#43888366)
What's the business usecase for incrementing a counter?

We can sit here all day and think up counterexamples, but in the real world what you're doing 99% of the time is:

1. Presenting a form, custom or static.

2. Filling out that form.

3. Loading a new page based off that form.

When I open my bank app or website, this is 100% of the experience. When I open my insurance company website, this is 100% of the experience. Hell, when I open apartments.com, this is like 98% of the experience. The 2% is that 3D view thingy they let you do.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Sunday May 04, 2025 @04:52PM (#43889475)
> What's the business usecase for incrementing a counter?

Notification count in the top right?

Remaining credit on an interactive service (like the ChatGPT web interface)?

So, maybe two(!) business use-cases out of thousands, but it's a pretty critical two use-cases.

I agree with you though - do all normal HTML form submissions, and for those two use-cases use `setInterval` to set them from a `fetch` every $X minutes (where you choose the value for $X).

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Monday May 05, 2025 @03:59AM (#43892807)
In my experience it's just exceedingly rare to require this. My insurance company website has a notification thing, and it's actually static. You need to refresh the page, and considering how few and far between notifications are, and how common refreshes are, it works fine.

There's an entire domain of apps where you truly need a front-end. Any desktop-like application. Like Google Sheets, or Figma. Where the user feedback loop is incredibly tight for most operations.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by yawaramin on Friday May 09, 2025 @03:30PM (#43940213)
Notification incrementing is not purely client-side state though. It's triggered by an event coming from a server. Eg let's say you're on a product page and you click 'Add to Cart'. You want the cart icon's counter badge on the top right corner of the page to increment. With eg htmx when you click 'Add to Cart' we send a request to the server, it updates the cart state in the backend, then sends an HTML fragment response that updates the necessary parts of the page, including the cart item counter badge.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by procaryote on Sunday May 04, 2025 @07:56AM (#43886223)
That sounds like the most basic of experiences...
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by stavros on Saturday May 03, 2025 @04:39PM (#43882108)
Not between page loads.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by tomnipotent on Saturday May 03, 2025 @05:04PM (#43882310)
You absolutely did. It was common practice to stuff things in cookies or query strings to retain state between trips to the server so that some JS could do its job.

Every form also normally ends up duplicating validation logic both in JS for client-side pre-submit UX and server-side with whatever errors it returns for the JS to then also need to support and show to the user.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by stavros on Saturday May 03, 2025 @05:20PM (#43882416)
Right, but validation logic and state transferred by the server isn't in-memory state. The fact that the pages completely reload on each request clears a lot of cruft that doesn't get cleared on pages whose lifetime is tens or hundreds of views.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by tomnipotent on Saturday May 03, 2025 @05:30PM (#43882488)
Every SPA I come across, especially when using React, uses persistent state so that in-memory changes are synced to cookie/localStorage/server so they survive refreshes. Every popular state management library even supports this natively. And all of that state combined still requires less memory than any of the images loaded, or the JS bundles themselves.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by actsasbuffoon on Saturday May 03, 2025 @06:17PM (#43882823)
I absolutely loathe that. State is the source of most bugs. If the page crashes then refreshing it should clear out the state and let me try again.

Anecdotally, it seems like I encounter a lot more web apps these days where refreshing doesn’t reset the state, so it’s just broken unless I dig into dev tools and start clearing out additional browser state, or removing params from the URL.

Knock it off with all the damn state! Did we forget the most important lesson of functional programming; that state is the root of all evil?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by SkepticalWhale on Saturday May 03, 2025 @08:15PM (#43883417)
Minimizing state simplifies the codebase but it’s a trade off.

There are times the user experience is just objectively better with more state, and you have to weigh the costs.

If I am filling out a very long form (or even multi-page form) I don’t really want all that state lost if I accidentally refresh the page.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by tomnipotent on Saturday May 03, 2025 @06:59PM (#43883049)
I can remember vastly more instances where I've been frustrated as a user of an app or website by losing state, than remember state.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by nine_k on Saturday May 03, 2025 @04:35PM (#43882070)
Unless you can guarantee RTT under 100ms, you have to manage some state on client side, else your UI will feel sluggish.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by freetonik on Saturday May 03, 2025 @06:09PM (#43882767)
I’d rather have sluggish UI with proper feedback than potentially inconsistent states which I often experience with modern SPAs. At least that represents reality. Just today I was posting an ad on the local classifieds page, and the visual (client) state convinced me that everything was fast and my photos are uploaded. Turned out all state was lost and never reached the server, and I had to redo everything again.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by const_cast on Saturday May 03, 2025 @06:31PM (#43882915)
It’s trivial to achieve under 100ms in the US with even just one server.

Most companies aren’t international.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ummonk on Saturday May 03, 2025 @09:26PM (#43883744)
Without keep-alive, any HTTPS request requires multiple round trips to complete.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ndriscoll on Sunday May 04, 2025 @08:56AM (#43886451)
Fortunately every browser made in the last 25 years supports keepalive. e.g. Firefox (and according the the reporter of this bug, Chrome) won't even let you disable it[0].

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=879002

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by devnull3 on Saturday May 03, 2025 @07:08PM (#43883088)
Barring the interactivity SPAs will also end up talking to server anyway. So even SPAs will feel sluggish in a high latency env.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by victorbjorklund on Monday May 05, 2025 @06:48AM (#43893599)
Phoenix Liveview works pretty good without client side state. Sure if you just have a toggle mobile menu you might sprinkle some JS for it but other state lives in the server and the delta is sent to the client via websockets
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ivan_gammel on Saturday May 03, 2025 @05:32PM (#43882511)
Client-server model is known for decades, state management between them isn’t hard.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ajb92 on Saturday May 03, 2025 @04:43PM (#43882141)
Who says your backend needs to manage state?
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by cstew913 on Saturday May 03, 2025 @05:21PM (#43882434)
You don't have a database?
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by throwaway7783 on Saturday May 03, 2025 @04:24PM (#43881955)
I have repeated this elsewhere. APIs for UI tend to diverge from APIs in general in practice.

For applications that are not highly interactive, you don't quite need a lot of tooling on the BE, and since need to have a BE anyway, a lot of standard tooling is already in there.

React style SPAs are useful in some cases, but most apps can live with HTMX style "SPA"s

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by whatnow37373 on Saturday May 03, 2025 @05:16PM (#43882392)
Agreed. We started with one API to rule them all. What happened? Now we got two.. and now we have to communicate like this:

“So the backend gave this weird …”

“What backend?”

“The backend for the frontend…”

“So not the backend for the backend for the frontend?”

I jest, but only very slightly.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by throwaway7783 on Saturday May 03, 2025 @06:44PM (#43882981)
Exactly. And state is in two places now. It's like building two applications and trying to somehow keep them in sync.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by recursivedoubts on Saturday May 03, 2025 @06:41PM (#43882963)
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by qudat on Sunday May 04, 2025 @09:02AM (#43886472)
> APIs for UI tend to diverge from APIs in general in practice.

I'm arguing to just use a single API, not creating one for UI, at least when you want things to be simple for multiple clients.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by __abc on Saturday May 03, 2025 @04:29PM (#43882014)
If you truly need for MVC to manage all things state, component communications, and complex IxD in the front-end, sure, but not every app has that level of front-end complexity to warrant a SPA, in my opinion.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by 0cf8612b2e1e on Saturday May 03, 2025 @04:30PM (#43882022)

  I think the DX is significantly better as well with fast reload…
As a user, the typical SPA offers a worse experience. Frequent empty pages with progress bars spinning before some small amount of text is rendered.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by brandensilva on Saturday May 03, 2025 @06:02PM (#43882724)
We have been moving to localized cache stores and there aren't any client side loaders anymore outside of the initial cache generation. Think like Linear, Figma, etc

It just depends on what you are after. You can completely drop the backend, apis, and have a real time web socketed sync layer that goes direct to the database. There is a row based permissions layer still here for security but you get the idea.

The client experience is important in our app and a backend just slows us down we have found.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by veqq on Saturday May 03, 2025 @06:54PM (#43883029)
> We have been moving to localized cache stores and there aren't any client side loaders anymore outside of the initial cache generation. Think like Linear, Figma, etc.

That's never the case.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by dingnuts on Saturday May 03, 2025 @06:43PM (#43882975)
>and have a real time web socketed sync layer that goes direct to the database

you might be able to drop a web router but pretending this is "completely drop[ping] the backend" is silly. Something is going to have to manage connections to the DB and you're not -- I seriously hope -- literally going to expose your DB socket to the wider Internet. Presumably you will have load balancing, DB replicas, and that sort of thing, as your scale increases.

This is setting aside just how complex managing a DB is. "completely drop the backend" except the most complicated part of it, sure. Minor details.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by threetonesun on Saturday May 03, 2025 @07:25PM (#43883170)
I assumed they meant a client side DB and then a wrapper that syncs it to some other storage, which wouldn't be terribly different than say a native application the relies on a cloud backed storage system.

Which is fine and cool for an app, but if you do something like this for say, a form for a doctor's office, I wish bad things upon you.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by zozbot234 on Saturday May 03, 2025 @04:34PM (#43882064)
> As a user, the typical SPA offers a worse experience.

Your typical SPA has loads of pointless roundtrips. SSR has no excess roundtrips by definition, but there's probably ways to build a 'SPA' experience that avoids these too. (E.g. the "HTML swap" approach others mentioned ITT tends to work quite well for that.)

The high compute overhead of typical 'vDOM diffing' approaches is also an issue of course, but at least you can pick something like Svelte/Solid JS to do away with that.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by int_19h on Saturday May 03, 2025 @06:02PM (#43882731)
My biggest annoyance with SPAs is that they usually break forward/back/history in various subtle (or not so subtle) ways.

Yes, I know that this can be made to work properly, in principle. The problem is that it requires effort that most web devs are apparently unwilling to spend. So in practice things are just broken.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jefozabuss on Saturday May 03, 2025 @06:54PM (#43883028)
I still have some ptsd from payment gateway integrations via iframes about 6-7 years ago. If you thought SPAs are bad by themselves for history tracking imagine those banking iframes randomly adding more entries via inside navigation/redirection that you have to track manually.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Saturday May 03, 2025 @09:38PM (#43883794)
A lot can be said for just putting a "back" button a page. I still do it occasionally for this very reason. Then again, my user base for the apps I write are the most non-technical folks imaginable, so many of them have no concept of a browser back button to begin with. I am not being hyperbolic either.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by int_19h on Saturday May 03, 2025 @10:09PM (#43883934)
Thing is, the browser back button is still there, though. So now you have two identical buttons that do different things. And that's really bad UX.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by creakingstairs on Saturday May 03, 2025 @10:51PM (#43884096)
I’m split on this. I used to agree with you but when I talked to internal users and customers, they really liked having a back button in the app. I would tell them the browser back button is there and we haven’t broken history so it should work to which they just often shrug and say they “just” prefer it.

My hypothesis is that they’ve had to deal with so many random web apps breaking the back button so that behaviour is no longer intuitive for them. So I don’t push back against in-app back buttons any more.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by int_19h on Sunday May 04, 2025 @04:27AM (#43885381)
It's okay if both buttons do the same thing. But OP (if I understood them correctly) proposed the in-app Back button as a hacky solution to the problem of browser one being broken, which kinda implies that they don't behave the same.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by syndeo on Monday May 05, 2025 @09:21AM (#43894846)
I think you're right on the money—those bad web apps that told people emphatically "do NOT use your browser's back button!" did the rest of us a lot of damage, as I really do agree that it trained many people to never press it unless they actually want to leave the app they're using.

I myself am guilty of (about 14 years ago now) giving an SPA a "reload" button, which had it go and fetch clean copies of the current view from the server. It was a social app; new comments and likes would automatically load in for the posts already visible, but NEW posts would NOT be loaded in, as they would cause too much content shift if they were to load in automatically.

Admittedly this is not a great solution, and looking back on it now, I can think of like 10 different better ways to solve that issue… but perhaps some users of that site are seeing my comment here, so yeah, guilt admitted haha.

/)

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by michaelcampbell on Monday May 05, 2025 @11:36AM (#43896226)
Bad UX that provides a functionality that otherwise isn't there at all is still better.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by skydhash on Saturday May 03, 2025 @07:19PM (#43883138)
An additional one for me is stale state. I can leave most webpages open for days, except SPAs. Especially on mobile.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by whatarethembits on Saturday May 03, 2025 @10:33PM (#43884030)
This issue doesn't get enough attention; apart from the obvious implications on bad UX, I find myself losing interest in a project after realising its broken in so many subtle and non-subtle ways due to the underlying tech. I, like many others, got into programming due to the joy of creating something beautiful and attempting to follow (influencer led) JS trends nearly killed my interest in this field at a time.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by molochai on Saturday May 03, 2025 @11:37PM (#43884290)
A small but silly one: breaking middle and right click functionality for links.

An auction site I use loads in the list of auctions after the rest of the page loads in, and also doesn't let you open links with middle click or right click>new tab, because the anchor elements don't have href attributes. So that site is a double-dose of having to open auctions in the same tab, then going back to the list page and losing my place in the list of auctions due to the late load-in and failure to save my scroll location.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pc86 on Sunday May 04, 2025 @09:21AM (#43886551)
I would submit this as product feedback if you haven't. One of my favorite things as a dev working on client-facing things is when I get negative feedback that presumably has a pretty easy fix to at least part of it ("add 'href' to these links") where I can pretty quickly make someone's life a little easier.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by yawaramin on Friday May 09, 2025 @10:56AM (#43937490)
Unless it's not a link but a <div onClick={loadItem}>...
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by HJain13 on Monday May 05, 2025 @03:41AM (#43892717)
This is not exclusive with an SPA. Even MPAs/SSR apps can have this issue. But I guess MPAs are probably not built with post load interactivity in mind and maybe that's why its less prevalent there.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by boomskats on Saturday May 03, 2025 @05:20PM (#43882425)
> Your typical SPA has loads of pointless roundtrips

This is an implementation choice/issue, not an SPA characteristic.

> there's probably ways to build a 'SPA' experience that avoids these too

PWAs/service workers with properly configured caching strategies can offer a better experience than SSR (again, when implemented properly).

> The high compute overhead...

I prefer to do state management/reconciliation on the client whenever it makes sense. It makes apps cheaper to host and can provide a better UX, especially on mobile.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by apothegm on Saturday May 03, 2025 @09:44PM (#43883815)
Except for a user on a lower specced device that can’t performantly handle filtering and joining on that mass of data in JS code, or perhaps can’t even hold the data in memory.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Sunday May 04, 2025 @04:41PM (#43889406)
> Except for a user on a lower specced device that can’t performantly handle filtering and joining on that mass of data in JS code, or perhaps can’t even hold the data in memory.

Just how low-spec and/or how much state-data are we talking about here? I ask only because I am downloading an entire dataset and doing all the logic on the client, and my PC is ancient.

I'm on a computer from 2011 (i7 870 @ 2.9GHz with 16MB of RAM), and the client-side filtering I do, even on a few dozens of thousand of records retrieved from the server, still takes under a second.

On my private app, my prospect list containing maybe 4k records, each pretty substantial (as they include history of engagements/interactions with that client) is faster to sort and filter on the client than it is to download the entire list.

I am usually waiting for 10s while the hefty dataset downloads, but the sorting and filtering happens in under a second. I do not consider that a poor UX.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by apothegm on Sunday May 04, 2025 @05:41PM (#43889821)
10s is painful. A server-rendered app should be able to deliver that data, already rendered, in closer to a fifth of a second. Fast enough that the user doesn’t even notice any wait.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Sunday May 04, 2025 @05:53PM (#43889903)
> 10s is painful. A server-rendered app should be able to deliver that data, already rendered, in closer to a fifth of a second.

How do you know how large the dataset is? All you know from my post is that a dataset that takes 10s to download (I'm indicating the size of it here!) takes under a second to filter and sort.

My point is that if your client-code is taking long to filter and sort, then your dataset is already so large that the user has been waiting a long time for it already; they already know that this dataset takes time.

FWIW, the data is coming in as CSV, compressed, so it's as small as possible. It's not limited by the server. Having it rendered by the server will increase the payload substantially.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by apothegm on Monday May 05, 2025 @11:47AM (#43896352)
The JS processing and rendering time on an underpowered CPU is the issue, not the payload size. It’s difficult to describe how excruciatingly slow some seemingly simple e-commerce and content sites are to render on my 2019 laptop or how slowly they react to something as simple as a mouseover or how they peg the CPU - while absolutely massively complex and large server-rendered HTML loads and renders in an eyeblink.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Monday May 05, 2025 @03:12PM (#43898390)
Which sites are you thinking off?

I can't really speak for those sites anyway, or why they are so slow doing things on the client, but like I said, I've written client-side processing and used my 2011 desktop, and there has been no pegging of the CPU or large latencies when filtering/sorting data client-side.

> while absolutely massively complex and large server-rendered HTML loads and renders in an eyeblink.

I've not had that experience - a full page refresh with about 10MB of data does not happen in an eyeblink. It takes about 6 seconds. There's a minimum amount of time for that data to download, regardless of whether it is pre-rendered into `<table>` elements or whether it is sent as JSON. Turning that JSON into a `<table>` on the client takes about 40ms on my 2011 desktop. Sorting it again takes about 5ms.

For this use-case (fairly large amounts of data), doing a full-page refresh each time the user sets a new sort criteria is unarguably a poorer experience than a bit of JS that goes through the table element and re-orders the `<tr>` elements.

In this case, using server-rendered HTML is always going to be 6000ms whenever the user re-sorts the table. Using a client JS function takes 5ms. On a machine purchased in 2011.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by apothegm on Monday May 05, 2025 @09:54PM (#43901142)
For sorting the table, perhaps. But for displaying the table in the first place? Static HTML is invariably faster in my experience. IMO there is just no excuse for placeholder elements with loading animations on a content or e-commerce site where it should be possible to provide all the content up front and add some very light JS on top to handle things like image carousels.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by lelanthran on Tuesday May 06, 2025 @07:25AM (#43903873)
> But for displaying the table in the first place? Static HTML is invariably faster in my experience.

Okay, lets assume it is faster by whatever the latency is for a network request.

What sort of use-case are we talking about where a table is displayed on a content or e-commerce side and the user is not allowed to re-sort it?

It's all about the user's experience, not the developer's, and I can't see how a UX that prevents sorting is a better UX. Ditto for a sortable table that refreshes the page each time the user sorts it.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by boomskats on Sunday May 04, 2025 @06:10PM (#43890021)
What mass of data? Can you give me an example of the kind of device and the kind of use case you're talking about?
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by smileysteve on Saturday May 03, 2025 @10:28PM (#43884011)
As an issue, yes, often ignored by QA, Product and engineers
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by eastbound on Saturday May 03, 2025 @04:49PM (#43882195)
Requires additional engineering.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by WuxiFingerHold on Saturday May 03, 2025 @11:37PM (#43884289)
Yes, pure old school SPAs have at least one additional roundtrip on the first visit of the site:

1. Fetch index.html 2. Fetch js, css and other assets 3. Load personalized data (json)

But usually step 1 and 2 are served from a cdn, so very fast. On subsequent requests, 1 and 2 are usually served from the browser cache, so extremely fast.

SSR is usually not faster. Most often slower. You can check yourself in your browser dev tools (network tab):

SPA: https://www.solidjs.com/

vs.

Poster child SSR: https://nextjs.org/

So much complexity and effort in the nextjs app, but so much slower.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by yawaramin on Friday May 09, 2025 @12:29PM (#43938618)
> Poster child SSR

That's not really SSR though, it's partial SSR but then hydrated into a client-side React app, so a SPA. If you really want to compare try an htmx page.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hombre_fatal on Sunday May 04, 2025 @12:08PM (#43887527)
> Your typical SPA has loads of pointless roundtrips. SSR has no excess roundtrips by definition

SSR also has excess round trips by nature. Without Javascript, posting a form or clicking a like button refreshes the whole page even though a single <span> changed from a "12 likes" to "13 likes".

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ai-christianson on Monday May 05, 2025 @07:15AM (#43893761)
I think most of the thread is talking about SSR with partial HTML replacement.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by WD-42 on Saturday May 03, 2025 @08:55PM (#43883602)
This exactly. It seems like the last 10 years of JavaScript framework progress has been driven by DX, not UX. Like at some point everyone forgot this crap just needs to work at the end of the day, no user benefits from 3 rewrites over 5 years because the developer community decided functions are better than classes.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ryantownsend on Sunday May 04, 2025 @10:42AM (#43886994)
In my view, DX should be renamed "Developer Convenience" as we all know that convenience is often a trade-off.

Please forgive the self-promotion but this was exactly the premise of a conference talk I gave ~18 months ago at performance.now() in Amsterdam: https://www.youtube.com/watch?v=f5felHJiACE

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by tomjuggler on Monday May 05, 2025 @11:40AM (#43896271)
That was super annoying when I was just picking up react.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by WuxiFingerHold on Saturday May 03, 2025 @11:27PM (#43884246)
There's no way around waiting for the data to arrive. Being it JSON for SPA or another page for MPA / SSR. For MPA the browser provides the loading spinner. Some SPA router implementations stay on the current page and route to the new one only after all the data has arrived (e.g. Sveltekit).
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by albedoa on Sunday May 04, 2025 @01:28AM (#43884709)
> For MPA the browser provides the loading spinner.

Yes, that one. I want that experience please.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by grey-area on Sunday May 04, 2025 @01:32AM (#43884722)
With SSR all the data usually arrives in 100-200ms, in SPAs all the data tends to take seconds to arrive on first load so they resort to spinners, loading bars etc.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by qudat on Sunday May 04, 2025 @08:50AM (#43886429)
If you employ a "preload then rehydrate" data sync paradigm then you should never see a blank page -- except on initial JS load. This is just an improper data sync strat and has nothing to do with SPA.

I built a lib specifically designed for this strat: https://starfx.bower.sh/learn#data-strategy-preload-then-ref...

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pc86 on Sunday May 04, 2025 @09:18AM (#43886542)
"Devs are doing SPAs wrong" is irrelevant when 90% of devs do SPAs that way. That it's wrong doesn't help the fact that most SPAs have garbage user experience.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by fideloper on Sunday May 04, 2025 @11:32AM (#43887288)
“just add more complexity”
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by switz on Saturday May 03, 2025 @04:36PM (#43882080)
So here's the kicker: React Server Components don't need a server. They are completely compatible with a static bundle and still provide major benefits should you choose to adopt them (dead code elimination, build-time execution). This is effectively the design of Astro Islands, natively in React Server Components. Letting you write static and client-side dynamic code in a single paradigm through componentization and composition.

If you are curious, my most recent blog post is all about this concept[0] which I wrote because people seem to be misinformed on what RSCs really are. But that post didn't gain any traction here on HN.

Is it more complex? Sure–but it is also more powerful & flexible. It's just a new paradigm, so people are put off by it.

[0] Server Components Give You Optionality https://saewitz.com/server-components-give-you-optionality

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by chipsrafferty on Saturday May 03, 2025 @05:57PM (#43882685)
Then they are poorly named.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by switz on Saturday May 03, 2025 @06:01PM (#43882714)
I generally agree. Naming things is among the hardest problems in computer science
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by dmix on Saturday May 03, 2025 @05:00PM (#43882278)
The obsession with DX tooling is exactly why JS is such an awful developer experience. They always chase something slightly better and constantly change things.

Maybe the answer was never in JS eating the entire frontend, and changing the tooling won’t make it better, as it’s always skirting what’s actually good for the web.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pier25 on Saturday May 03, 2025 @05:18PM (#43882402)
> The obsession with DX tooling is exactly why JS is such an awful developer experience.

I used to agree but these days with Vite things are a lot smoother. To the point that I wouldn't want to work on UI without fine-grained hot reloads.

Even with auto reload in PHP, .NET, etc you will be wasting so much time. Especially if you're working on something that requires interaction with the page that you will be repeating over and over again.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by dmix on Saturday May 03, 2025 @05:32PM (#43882514)
> Especially if you're working on something that requires interaction with the page that you will be repeating over and over again.

That’s honestly not that many things IRL. If you look at all the things you build only a minority actual demand high interactivity, or highly custom JS. Otherwise existing UI libraries cover the bulk of what people actually need to do on the internet (ie, not just whatever overly fancy original idea the designers think is needed for your special product idea).

It’s mostly just dropdowns and text and tables etc.

Once you try moving away from all of that and questioning if you need it at every step you’ll realize you really don’t.

It should be server driven web by default with a splattering of high functionality islands of JS. That’s what rails figured out after changing the frontend back and forth.

> Even with auto reload in PHP, .NET, etc you will be wasting so much time

Rails has a library that will refresh the page when files change without a full reload, using Turbo/Hotwire. Not quite HMR but it’s not massively different if your page isn’t a giant pile of JS, and loads quickly already.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pier25 on Sunday May 04, 2025 @12:02AM (#43884385)
> Rails has a library that will refresh the page when files change without a full reload

What if you have a modal opened with some state?

Or a form filled with data?

Or some multi-selection in a list of items that triggers a menu of actions on those items?

Etc.

And it's true Vite can't always do HMR but it's still better than the alternative.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by timr on Sunday May 04, 2025 @05:52AM (#43885721)
> What if you have a modal opened with some state?

Stimulus controllers can store state.

> Or a form filled with data?

Again, you can either use a Stimulus controller, or you can just render the data into the form response, depending on the situation.

> Or some multi-selection in a list of items that triggers a menu of actions on those items?

So, submenus? Again, you can either do it in a Stimulus controller (you can even trivially do things like provide a new submenu on the fly via Turbo), or you can pre-render the entire menu tree server-side and update just the portion that changes.

None of these are complex examples.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pier25 on Monday May 05, 2025 @11:20AM (#43896040)
> Stimulus controllers can store state.

Yes, obviously, but do these maintain state after hot reload?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by timr on Tuesday May 06, 2025 @01:45AM (#43902144)
We're talking about two entirely different things that lead to the same outcome. The approach we're describing is not a "hot reload" per se, it's just selectively updating the changed contents of the page. For the vast majority of the changes you do during development, this is invisible to you.

If you change the JS or the controller itself, obviously, state stored in JS would be lost unless you persisted it locally somehow.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ToucanLoucan on Saturday May 03, 2025 @07:35PM (#43883228)
> I used to agree but these days with Vite things are a lot smoother.

Didn't everybody say the exact same thing about Node, React, jQuery...? There is always a new and shiny frontend JS solution that will make the web dev of old obsolete and everyone loves it because it's new and shiny, and then a fresh crop of devs graduates school, the new shiny solution is now old and boring, and like a developer with untreated ADHD, they set out to fix the situation with a new frontend framework, still written in JavaScript, that will solve it once and for all.

I still build websites now the same as I did when I graduated in 2013. PHP, SQL, and native, boring JavaScript where required. My web apps are snappy and responsive, no loading bars or never-ending-spinning emblems in sight. shrug

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by petre on Saturday May 03, 2025 @11:34PM (#43884280)
Except you can't really build PWAs with those technologies and most web content is now consumed on mobile. I used to do it like that as well, but clients want a mobile app and management decided to give them a PWA, because then we could use the existing backend (Perl, Mojolicious, SQL). I now agree with them if it keeps the lights on.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jjani on Sunday May 04, 2025 @12:34AM (#43884513)
> I used to do it like that as well, but clients want a mobile app and management decided to give them a PWA

I'm quite surprised to hear this is a common thing. Besides myself, I don't know a single person who has ever installed a PWA. For people in tech, despite knowing they exist. For people outside tech, they don't know they exist in the first place.

Does management actually have any PWAs installed themselves?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ivan_gammel on Sunday May 04, 2025 @04:00AM (#43885280)
People outside tech just get installation instructions and do not care if it’s app store or something else. This is how sanctioned Russian banks continue to serve their customers via apps, when they cannot get into app store. The number of users of PWA is probably on the scale of millions.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jjani on Sunday May 04, 2025 @04:24AM (#43885368)
I had no idea! Cool to learn.

It definitely makes complete sense in that scenario, but remains a very niche usecase where people have no other option.

>People outside tech just get installation instructions

People outside of tech don't need instructions to install non-PWA, store apps. So all this does to me is reinforce that no one is installing PWAs outside of niche scenarios where 1. people basically have to use the app due to a connection to a physical institution 2. they are explicitly told how to do it 3. the app is not available on the stores for legal reasons.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ivan_gammel on Sunday May 04, 2025 @05:49AM (#43885704)
> People outside of tech don't need instructions to install non-PWA, store apps.

Depends on age and tech awareness. Many still do, when they cannot rely on a family member to do it for them. Overall installing PWA is no more complicated than getting something from a store.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by Scarblac on Sunday May 04, 2025 @10:00AM (#43886749)
That sounds like roughly all work related software? Not so niche at all.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jjani on Monday May 05, 2025 @02:59PM (#43898270)
Who uses PWA for work-related apps though? There too, the standard is MDN which uses a curated version of the app stores.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pjmlp on Sunday May 04, 2025 @01:01AM (#43884602)
For me the whole worker setup filtering requests and storing results on local storage, looks like gimmicks.

They should have designed it as a proper native experience.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by petre on Sunday May 04, 2025 @02:20AM (#43884907)
They don't want to be subject to app store approval policies, shitty TOS, nor pay Google or Apple a 30% cut. Installing the app is easy, visit the web site, clck the install banner, add to home screen and you're good to go. On the developer side you get to deploy as iften as needed.

Yes, the service worker thing is annoying but you possibly don't need it if you have a server backend. It's basically a glirified website with a home screen icon. Most of the native vehicle, asset or fitness tracking apps need a backend anyways and they fail miserably when disconnected from the network.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pjmlp on Sunday May 04, 2025 @02:27AM (#43884927)
Might be easier for the user, sucks as developer experience.

Better do a mobile Web friendly website and leave it at that.

Most users hardly tell the difference anyway.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jjani on Sunday May 04, 2025 @04:21AM (#43885353)
> They don't want to be subject to app store approval policies, shitty TOS, nor pay Google or Apple a 30% cut. Installing the app is easy, visit the web site, clck the install banner, add to home screen and you're good to go. On the developer side you get to deploy as iften as needed.

And the metrics are saying that people click it?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by petre on Sunday May 04, 2025 @02:49PM (#43888592)
We don't care about people clicking it as it's not tiktok but an app that complements a certain hardware solution. If you don't have the hardware, you don't need the app.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by pjmlp on Sunday May 04, 2025 @01:00AM (#43884598)
Just focus on being mobile friendly, hardly anyone cares about PWAs and the crazy setup of JavaScript workers to make it work.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ezekiel68 on Saturday May 03, 2025 @05:56PM (#43882673)
>To the point that I wouldn't want to work on UI without fine-grained hot reloads.

No -- but you could. And it wouldn't be the end of the world. So I'm just saying, DX doesn't eclipse all other considerations.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by ivan_gammel on Saturday May 03, 2025 @05:29PM (#43882479)
Eh, I recently stumbled into an open bug in Npm/vite and wasted two days before just reinstalling everything and re-creating frontend app. Hot UI reloads are cool, but such things kill any productivity improvements.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by jimbob45 on Saturday May 03, 2025 @08:12PM (#43883404)
There’s just no way for the abominations that are HTML, JS, and CSS to be used in an accessible and maintainable way. It’s absurd that we haven’t moved on to better technologies in the browser or at least enabled alternatives (I weep for Silverlight).
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Saturday May 03, 2025 @09:41PM (#43883804)
> (I weep for Silverlight).

'Twas before my time. What was so great about it? I remember needing it installed for Netflix like 15 years ago. Did you ever work with Flash? How was that?

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by qudat on Sunday May 04, 2025 @08:54AM (#43886443)
Hmm, JS is "different" because it has completely unique challenges that no other programming language has to deal with: https://bower.sh/my-love-letter-to-front-end-web-development
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by whatnow37373 on Saturday May 03, 2025 @05:12PM (#43882363)
> dramatically reduce complexity

If you ever worked seriously on anything non-SPA you would never, ever claim SPAs “dramatically reduce complexity”. The mountain of shit you have pull in to do anything is astronomical even by PHPs standards and I hate PHP. Those days were clean compared to what I have to endure with React and friends.

The API argument never sat well with me either. Having an API is orthogonal: you can have one or do not have one, you can have one and have a SSR app. In the AI age an API is the easy part anyway.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by cjonas on Saturday May 03, 2025 @07:54PM (#43883324)
> You still have to deal with all the tooling you are talking about, right? You’ve just moved the goalpost to the BE

This. From a security perspective, server side dependencies are way more dangerous than client side.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by t-writescode on Saturday May 03, 2025 @09:08PM (#43883656)
You can accomplish the "don't have to reload the page to see my changes" with htmx and it's still "server-side rendering" (or mostly server-side rendering). Legendarily, the fastest website on the internet uses partial page caching to achieve its speed
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Saturday May 03, 2025 @09:46PM (#43883825)
What do you like about HTMX? I coming from a world of plain JS usage -- no SPAs or the like. I just felt like HTMX was just a more complicated way to write what could be simple .fetch() requests.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by t-writescode on Saturday May 03, 2025 @10:02PM (#43883898)
I like that it still feels like html. I think that's it's biggest selling point.

You write:

  <div id="moo" />
  <form hx-put="/foo" hx-swap="outerHTML" hx-target="#moo">
     <input hidden name="a" value="bar" />
     <button name="b" value="thing">Send</button>
  </form>
Compared to (ChatGPT helped me write this one, so maybe it could be shorter, but not that much shorter, I don't think?):

  <div id="moo" />
  <form>
     <input hidden name="a" value="bar" />
     <button name="b" value="thing" onclick="handleSubmit(event)" >Send</button>
  </form>

  <script>
  async function handleSubmit(event) {
    event.preventDefault();
  
    // the form submit stuff
    const form = event.target.form;
    const formData = new FormData(form);

    const submitter = event.target;
    if (submitter && submitter.name) {
      formData.append(submitter.name, submitter.value);
    }

    // hx-put
    const response = await fetch('/foo', {
      method: 'PUT',
      body: formData,
    });

    / hx-swap
    if (response.ok) {
      const html = await response.text();
      // hx-target
      const target = document.getElementById('moo');
      const temp = document.createElement('div');
      temp.innerHTML = html;
      target.replaceWith(temp.firstElementChild);
    }
  }
  </script>
And the former just seems, to me at least, way way *way* easier to read, especially if you're inserting those all over your code.
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Monday May 05, 2025 @12:03PM (#43896510)
Yeah, the JS could technically be shorter, but your example is functional enough to get the point across.

Going with your example, how would you do proper validation with HTMX? For example, the input element's value cannot be null or empty. If the validation fails, then a message or something is displayed. If the validation is successful, then that HTML is replace with whatever?

I have successfully gotten this to work in HTMX before. However, I had to rely on the JS API for that is outside the realm of plain HTML attribute-based HTMX. At that point, especially when you have many inputs like this, the amount of work one has to do with the HTMX JS API starts to look at lot like the script tag in your example, but I would argue it's actually much more annoying to deal with.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by recursivedoubts on Monday May 05, 2025 @01:28PM (#43897370)
two possible approaches:

1. Do the validation server side and replace the input (or a label next to the input, see https://htmx.org/examples/inline-validation/)

2. Use the HTML 5 Client Side form validation API, which htmx respects:

https://developer.mozilla.org/en-US/docs/Learn_web_developme...

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Tuesday May 06, 2025 @01:02PM (#43907315)
Well, I never expected to get a reply from the man himself. Thank you for taking the time to respond.

So, I did end up going with #1 with a slight variation.

You also commented on another comment of mine stating:

> if you are using the htmx javascript API extensively rather than the attributes, you are not using htmx as it was intended

There seems to be some confusion, and I apologize. I extensively used attributes. That wasn't the part of the API I was referring to. Rather, I should have specified that I was heavily relying on a lot of the htmx.on() and html.trigger() methods. My usage of htmx.trigger() was predominately due to something being triggered on page load, but also, it needed to be triggered again if a certain condition was met -- to refetch the html with the new data -- if that makes sense.

I should also preface that I was working on this project about two years ago. It looks like a lot has changed with HTMX since then!

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by yawaramin on Friday May 09, 2025 @03:54PM (#43940370)
> At that point, especially when you have many inputs like this, the amount of work one has to do with the HTMX JS API starts to look at lot like the script tag in your example

Not sure exactly what you're talking about w.r.t 'the amount of work one has to do with the HTMX JS API', but I've found that form validation with htmx and a backend server works really well with just a tiny bit of JS and a little care crafting the backend's validation error response: https://dev.to/yawaramin/handling-form-errors-in-htmx-3ncg

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by recursivedoubts on Saturday May 03, 2025 @11:07PM (#43884161)
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by hirvi74 on Monday May 05, 2025 @12:07PM (#43896543)
I appreciate the suggestion. Not sure I am a fan of this implementation though. It looks near identical to the HTMX JS API that is already backed into HTMX. Most of the annoyances I dealt with were around conditional logic based on validation.

After enough of the HTMX JS API, I figured, "What is HTMX even buying me at this point?" Even if plain JS is more verbose, that verbosity comes with far less opinions and constraints.

Re:We Fell Out of Love with Next.js and Back in Love with Ru... by recursivedoubts on Monday May 05, 2025 @01:26PM (#43897352)
if you are using the htmx javascript API extensively rather than the attributes, you are not using htmx as it was intended
Re:We Fell Out of Love with Next.js and Back in Love with Ru... by myflash13 on Sunday May 04, 2025 @08:42AM (#43886392)
With an SPA you're writing two apps that talk to each other instead of one. That is, by definition, more complex.

> You still have to deal with all the tooling you are talking about, right? You’ve just moved the goalpost to the BE.

Now you're dealing with 2 sets of tooling instead of 1.

> And just like the specific use cases you mentioned for client routing I can also argue that many sites don’t care about SEO or first paint so those are non features.

There is no app which would not care about first paint. It's literally the first part of any user experience.

> So honestly I would argue for SPA over a server framework as it can dramatically reduce complexity. I think this is especially true when you must have an API because of multiple clients.

So SEO and first paint are not necessary features, but an API for multiple clients is? Most apps I've worked with for over 15 years of web dev never needed to have an API.

> I think the DX is significantly better as well with fast reload where I don’t have to reload the page to see my changes.

With backend apps the reload IS fast. SPA's have to invent tooling like fast reload and optimistic updates to solve problems they created. With server apps, you just don't have these problems in the first place.