News for hackers. Stuff that matters.
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.