News for hackers. Stuff that matters.
Re:SPAs Were a Mistake by Zanfa on Wednesday March 02, 2022 @11:30AM (#30529148)
I think one of the unsolved problems of client-side interactivity on websites is how difficult it is to add it just a little bit of extra client-side functionality to a traditional server rendered website. For example, recently I had to deal with photo uploads on a Rails app, which works fine out of the box at first, until you want to show progress bars and uploaded previews etc. Then you add a couple of client-side Stimulus controllers, maybe a Turbo frame here and there and it works, but then you get to browser navigation and you're screwed, because none of this works if somebody were to submit the form, then navigate back. Now you have to implement lifecycle handling to account for navigation and once you're done, you've basically implemented a SPA, except it's broken into a mix of tightly-coupled Javascript, Ruby and ERB templates.
Re:SPAs Were a Mistake by dlisboa on Wednesday March 02, 2022 @01:42PM (#30531059)
The problem is the mixing and matching of state management. In a traditional web app all of the state is in the back end, in a SPA all of the state is in the front end. When we share state in between the two it's often messy.

To me the answer feels like it should be "traditional web app for most things, components-as-first-intended for some things". The simplest React example is just one component that abstracts presentation and logic. The only state is its own. It does not handle an entire web app as a SPA, no Redux, prop drilling, it's just the idea of a reusable component as an HTML tag. Same with VueJS and all. If we restrict ourselves to that we're in the good path.

If there was already an HTML tag for your own specific problem, wouldn't you just use it in your traditional server-rendered app? A `<photo-upload url="/photos">` tag that does exactly what you want. Or a `<wizard pages=5 logic="com.domain">` tag. We should create just those components, either in React/VueJS/Whatever or in vanilla JS Web Components, and live with the rest as we used to.

We're basically saying that some parts of our apps are too difficult to mix and match state management, and we should offload all of the state to one of the two sides. In some rare apps indeed all of the state should be on the front end, but the use cases for that are just not as big as they're made out to be.

Re:SPAs Were a Mistake by prmph on Wednesday March 02, 2022 @01:54PM (#30531240)
Exactly, the best approach seems to be where the app is composed of traditional pages with server navigation between them, but each page is implemented as an SPA.

This approach eliminates the need for a client-side router, keeps any centralized page state small, and improves the SEO and bookmarkability of the app.

I have implemented this architecture in several projects, and it’s effective

Re:SPAs Were a Mistake by dlisboa on Wednesday March 02, 2022 @02:08PM (#30531428)
I disagree with that. There's no real reason for each page to be a separate SPA, most likely only a small part of that page will be interactive, and most of it will be cacheable. Extracting only the interactive parts of a page into components is what I'm talking about. In some cases that'll be all of the page, but there are very few apps that meet that criteria.
Re:SPAs Were a Mistake by prmph on Wednesday March 02, 2022 @02:14PM (#30531516)
Of course if only a small part of your app is interactive, then SPAs don’t come into the picture in the first place.

My point is that for very interactive web apps, this is a significantly better architecture that a huge monolithic SPA

Re:SPAs Were a Mistake by tracker1 on Wednesday March 02, 2022 @06:53PM (#30535212)
Not only that but bundle splitting allows for extra areas of the application to be loaded at runtime on demand.

All of that said, I'm not opposed to approaches like Next/Nuxt/Aleph.

Re:SPAs Were a Mistake by LAC-Tech on Wednesday March 02, 2022 @05:02PM (#30533829)
I mean in this model, if each page is an SPA, then the line between an SPA and an interactive page is very blurry.
Re:SPAs Were a Mistake by LAC-Tech on Wednesday March 02, 2022 @04:56PM (#30533751)
I've had this thought experiment before, but where I get stuck is - what happens when you want to share state between the pages? URL params, storing to indexedDB, sticking them in global variables - all viable solutions but all with their own issues.

I'd be very interested to hear how you solve this, or if it's less of an issue than people might think.

Re:SPAs Were a Mistake by SinParadise on Wednesday March 02, 2022 @03:07PM (#30532296)
>app is composed of traditional pages with server navigation between them, but each page is implemented as an SPA.

I agree with this because you affirm my bias.

Also because I've also had success implementing this structure. This makes sure that state of each page doesn't leak everywhere, which simplifies the state management.

It also loads faster than a big SPA because you don't have to worry about bundle splitting!

Re:SPAs Were a Mistake by trevex on Wednesday March 02, 2022 @02:06PM (#30531409)
Isn’t this basically what NextJS and NuxtJS provide, if you only leverage their static rendering?
Re:SPAs Were a Mistake by hughrr on Wednesday March 02, 2022 @02:07PM (#30531417)
The correct answer for this stuff, and it absolutely kills me saying this, is probably something like asp.net web forms.
Re:SPAs Were a Mistake by UglyToad on Wednesday March 02, 2022 @02:54PM (#30532095)
Yeah, as much pain as it has caused me in the past I think the crucial realization Microsoft made with Webforms and maybe Blazor is that the stateless model of web is fairly crap if you are doing anything beyond displaying static text.

For its time it was some cool tech.

Re:SPAs Were a Mistake by mattmanser on Wednesday March 02, 2022 @02:29PM (#30531729)
Asp.net web forms absolutely sucked. They fundamentally misunderstood HTML and how the internet even worked.

Modern Razor's pretty good (not Razor Pages, they also suck) which is probably what you mean.

But it's not that much different from Rails, Laravel, Django, etc.

Re:SPAs Were a Mistake by hughrr on Wednesday March 02, 2022 @02:39PM (#30531871)
Yes I mean the original version of it.

I'd love to watch people attempt to implement some of the stuff I pulled off with that back in the day now. Occasionally, very complex data driven page flows are required and you could nail that entire problem domain trivially with them.

There is a very large and well known company with a front-facing product used by millions of people which took 5 years pissing around with three different front end technologies to reimplement what we did in 3 months with that and it was slower and heavier and basically reimplemented web forms in python in the end.

It broke the the www intentionally because it sucked. And it still does.

Re:SPAs Were a Mistake by naasking on Wednesday March 02, 2022 @08:33PM (#30535980)
Speaking as someone who is still maintaining a web forms app, that sounds like a people problem, not a tech problem. You can implement literally any workflow if you understand continuations, and it will be simpler and more lightweight than web forms.

If you don't understand continuations, then you'll struggle and invent all sorts of poor state management patterns. Web forms simplifies some of this because the continuation is captured in viewstate, but it captures too much state (there are other warts too of course).

Re:SPAs Were a Mistake by manigandham on Wednesday March 02, 2022 @03:13PM (#30532391)
What’s wrong with razor pages? They’re fantastically simple and productive.

And WebForms wasn't a misunderstanding. It was a deliberate and brilliant design that brought WinForm developers and their experience to the web and allowed them to build complex web apps two decades ago that still work to this day.

Re:SPAs Were a Mistake by mattmanser on Thursday March 03, 2022 @05:20AM (#30539270)
Yeah, and as soon as soon as they tried doing that, they found out it was all superficial and the fact that there was HTTP calls inbetween meant everything started falling over and they saw weird behaviour. And instead of learning how to work with state management in general, they learnt how to work with WebForm's state management instead.

I'm working on one of those webforms projects right now, a legacy project that they need some fairly trivial tweaks to and it's an absolute nightmare of bad code. And I've done this before, it's become an accidental skill that I can still fix these awful messes.

One of the (many) reasons why webforms and the new Razor Pages are bad is because the code gets split up according to the UI instead of by function. So it gets scattered all over the place and is incredibly hard to do maintenance work on it.

The page-centric code layout that Webforms/Razor Pages/all the old PHP/Perl/etc. encourage is also extremely conducive in encouraging copy-and-pasta code for programmers trying to get stuff done asap.

So not only is it a nightmare to pick apart the code, you can often fine 2 or 3 copies of the same code that you only discover when one page is working as expected, but the same functionality is used somewhere else but someone just copied the page/control instead of actually splitting the page up into controls and re-using functionality.

I've seen this happen over and over and over. A single developer can avoid these pitfalls, a team cannot.

Re:SPAs Were a Mistake by zerkten on Wednesday March 02, 2022 @03:55PM (#30532998)
It's contextual. For me, WebForms fell down because it let the average web developer impose too many "costs" on internet-facing projects. A WinForms developer is a very specific kind of developer with a high focus on development of internal, or line-of-business (LOB) apps. WebForms also excelled at this, but brought more reach as people moved away from a preference for desktop apps.

The height of WebForms coincided with an embrace of web standards and accessibility which flows into the Web 2.0 era. You had to jump through a lot of hoops to achieve what was needed WebForms to get it to behave in a web-friendly way. The underlying .NET framework and base of ASP.NET (HttpHandler and HttpModule) was outstanding though.

(I still build/maintain WinForms, ASP.NET, and WPF apps.)

Re:SPAs Were a Mistake by CRConrad on Saturday March 12, 2022 @02:28PM (#30654095)
> people moved away from a preference for desktop apps.

Who did; which "people"?

Corporations and "Web developers" maybe; users never asked for it AFAIK.

Re:SPAs Were a Mistake by UltraViolence on Thursday March 03, 2022 @11:25AM (#30543024)
WebForms was a complete disaster, made solely to allow Microsoft salesmen to quickly slap together a demo.

The problems started when you wanted to put together a REAL application. Because the entire paradigm of a web application programmed like a desktop application was flawed it resulted into an endless stream of headaches and workarounds, with bloated, complex and slow applications as a result.

In that sense ASP.NET MVC was a breath of fresh air.

Re:SPAs Were a Mistake by tracker1 on Wednesday March 02, 2022 @06:56PM (#30535241)
I just remember massive state being injected into forms, and it wasn't pretty, was massive at times and just unpleasant regarding WebForms. It was fine for internal apps with a network connection, the experience was horrible if you were a dialup user. Especially in components that a change triggered effectively a full server round trip to update the whole page.

It got better by ASP.Net 3, but MVC/Razor was much, much better imo.

Re:SPAs Were a Mistake by marcos100 on Thursday March 03, 2022 @07:56AM (#30540298)
By Modern Razor you mean Blazor components?
Re:SPAs Were a Mistake by UltraViolence on Thursday March 03, 2022 @11:27AM (#30543051)
Razor Pages.
Re:SPAs Were a Mistake by chrisweekly on Wednesday March 02, 2022 @03:52PM (#30532952)
Please, go learn about Remix (https://remix.run), it is the actual correct answer for this stuff.
Re:SPAs Were a Mistake by pphysch on Wednesday March 02, 2022 @04:42PM (#30533590)
I don't understand why they choose an example -- a simple user dashboard -- that could be easily implemented as a traditional MPA. It seems like Remix is mainly for the "I learned to program with SPAs" audience.
Re:SPAs Were a Mistake by chrisweekly on Wednesday March 02, 2022 @08:33PM (#30535981)
Remix's _messaging_ may be aimed at the "SPA generation", but its capabilities are light years beyond a Rails w/ Turbolinks or whatever your concept of a traditional MPA might use. I'd encourage you to look a little closer.

My kneejerk rxn was "clearly you don't get it" -- but your critique and (mis)perception speak to their marketing / messaging, which, well, yeah, this is the world we live in. SPA has become the default, and Remix is pushing back on that, hard, and I'm stoked.

I've been doing webdev for a living since 1998, and Remix (like https://every-layout.dev 's "axiomatic css" - but I digress) is doing something profoundly powerful by leveraging the amazing power of the web platform on its terms, using the native APIs, and doing much, much more by being simpler and doing less. It's so refreshing.

Re:SPAs Were a Mistake by manigandham on Wednesday March 02, 2022 @03:14PM (#30532409)
Why does it kill you to say that? It’s the better and more productive option.
Re:SPAs Were a Mistake by hughrr on Wednesday March 02, 2022 @03:15PM (#30532428)
Because I abandoned it thinking it was terrible. Then I spent a decade finding out how bad everything else was.
Re:SPAs Were a Mistake by KwisaksHaderach on Wednesday March 02, 2022 @07:21PM (#30535414)
JS frameworks with a small footprint are suitable for this.
Re:SPAs Were a Mistake by WillPostForFood on Wednesday March 02, 2022 @01:59PM (#30531296)
Do you lose performance because each page has to load the SPA?
Re:SPAs Were a Mistake by unfocussed_mike on Wednesday March 02, 2022 @02:26PM (#30531675)
Not if the SPA subsequently takes over, (internally) routing links it recognises. (Nuxt does this)
Re:SPAs Were a Mistake by prmph on Wednesday March 02, 2022 @02:09PM (#30531441)
Not much, if you use dynamic loading for heavy functionality that may not be used.
Re:SPAs Were a Mistake by jkcxn on Wednesday March 02, 2022 @04:16PM (#30533278)
Yes this is exactly right. What I’ve done in the past is use Django to return HTML with JSX mixed in, and have a super lightweight SPA frontend that just hydrates the react components on each load. You can also use form state to communicate back and forth with the server, where sending a response doesn’t refresh the entire page, just a react render diff. With this you get the best of both worlds where your backend can do the heavy lifting where everything it needs to decide on the view is all in one place, and your frontend just comprises of really really generic JS components.

I have a library I’ve been playing around with for 2 years now, I should package it up

Re:SPAs Were a Mistake by CRConrad on Saturday March 12, 2022 @02:35PM (#30654168)
> I have a library I’ve been playing around with for 2 years now, I should package it up

Please do.

Re:SPAs Were a Mistake by ithrow on Wednesday March 02, 2022 @03:12PM (#30532378)
Agree, we just add React components here and there to server-side rendered HTML and it works great for us. The issue is most companies want separate teams for front-end and back-end and each team wants clear separation of boundaries and responsibilities between them.
Re:SPAs Were a Mistake by dzhiurgis on Wednesday March 02, 2022 @11:12PM (#30537090)
The old mythical man month strikes back. Best devops is no ops. Best team is no team.

Of course eventually you need more people and I don't love anyone touch my code, but I'd rather have someone incompetent do entire stack that at least I can review than spend weeks upon weeks communicating basic assumptions.

Re:SPAs Were a Mistake by beebeepka on Wednesday March 02, 2022 @04:09PM (#30533183)
Adding components here and there sounds like a simple app. Nothing wrong with that, if course.

Different teams exist for a reason. I've deeply regretted working in "we have real Devs that can do it all" environments.

It's not so much about boundaries as it is about competence. Or lack of it with

Re:SPAs Were a Mistake by khimaros on Wednesday March 02, 2022 @04:22PM (#30533356)
this seems to be approximately what https://htmx.org/ is trying to accomplish.
Re:SPAs Were a Mistake by dlisboa on Wednesday March 02, 2022 @05:05PM (#30533862)
HTMX goes about it in the wrong way, in my opinion. HTML code should not carry state and logic. The moment you need something a bit more complicated than the common examples you’re in HTML-attribute soup trying to use a real programming language.

It’s better to just write that as a component in React or Svelte or whatever. It’s more testable, easier to understand, can carry state and logic just fine. It does mean you have to communicate in JSON for a small part of your app, but that is reserved to a few well known endpoints and components like a complex form.

The penalty is loading React or some other lib just for that, but if used in this way the extra dependency isn’t really a big deal as it’s not your whole app. Just use React as a library for components the browser doesn’t already provide.

And by components here I should really clarify as “affordances”. A “primary” button isn’t an affordance, the browser already gives you a button element and CSS classes (or HTML attribute) for that. It doesn’t give you a “multi page wizard with immediate validation” affordance, however, so that’s a good candidate for a component.

Re:SPAs Were a Mistake by recursivedoubts on Wednesday March 02, 2022 @08:26PM (#30535938)
the original network model of the web was REST[1]

a core aspect of REST was HATEOAS, which stands for Hypermedia As The Engine of Application State[2]

htmx goes about it in the same way as the original web

perhaps that is wrong, but the web was pretty successful overall

[1] - https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arc... [2] - https://htmx.org/essays/hateoas/

Re:SPAs Were a Mistake by catlifeonmars on Wednesday March 02, 2022 @10:42PM (#30536892)
> perhaps that is wrong, but the web was pretty successful overall

Since HATEOAS is rarely implemented fully in practice, it would be simplistic to point to it as the reason the web is successful. The web allows an incredible variety of different architectures —- Some more closely aligned to HATEOAS and some less so. Perhaps this is the reason for the success of the web?

Re:SPAs Were a Mistake by recursivedoubts on Thursday March 03, 2022 @10:44PM (#30550450)
HATEOAS was and is implemented widely and effortlessly in hypermedia, since Fielding was describing the existing web architecture. It has failed fairly dramatically in JSON APIs, because JSON is not a native hypertext. Early API designers tried to shoehorn HATEOAS concepts into their APIs, which was somewhat plausible when APIs were XML, which, when squinted at, looked sort of like a hypermedia. Once we kicked over to JSON (and back to RPC as a network architecture) it became silly.
Re:SPAs Were a Mistake by catlifeonmars on Saturday March 05, 2022 @11:40AM (#30568990)
I’m not arguing against that, just that huge chunks of the web break the HATEOAS abstraction, as it were, and yet, as you pointed out, “the web is pretty successful overall”. It’s not super clear to me that this is because of hypermedia or not in the sense that correlation is not causality.
Re:SPAs Were a Mistake by CRConrad on Saturday March 12, 2022 @03:21PM (#30654560)
The Web went all JavaScript instead of HTML sometime between 2000(2005?) and 2010(2015?). But by 2000 it was already wildly successful, so apparently it must have been HTML -- "hypermedia" -- that was the key to success, not JavaScript / JSON.
Re:SPAs Were a Mistake by dlisboa on Thursday March 03, 2022 @08:19AM (#30540583)
HATEOAS is great, but that's not my issue with HTMX. It's coding interactivity via HTML attributes that I have an issue with. It just never works. It overcomplicates things and there's an actual programming language right there in JavaScript to solve this.

When it goes past the simplest examples it gets ugly real quick. Here's an example of client-side validation via HTMX: https://htmx.org/docs/#validation. That can't be the future.

Re:SPAs Were a Mistake by recursivedoubts on Thursday March 03, 2022 @09:56PM (#30550099)
yes, if you want to do things client side, hypermedia isn't going to be a great solution for you

htmx integrates with the existing HTML 5 validation API because, well, it's there, and that's what normal HTML does. I don't care much for the API, but that's the standard so we follow it. You can, of course, do client side validation however you'd like and integrate it with htmx using events, since events are the proper glue to tie things together in the DOM. I built a scripting language to help with this, and other stuff as well, called hyperscript: https://hyperscript.org

the "htmx" way for validation is the HTML/web 1.0/HATEOAS way: submit the form to the client side, validate and re-render. With htmx that can be inline, rather than a big clunky refresh-the-page action, which is why I say htmx extends and completes HTML as a hypermedia.

So long as you aren't willing to think about things in hypermedia terms, and htmx as an extension/completion of HTML as a hypermedia, you are going to miss the point. That's not to say that the hypermedia approach is always right, it isn't, but with htmx a lot more of the web application problem space is addressable with that approach.

And, as an aside, HATEOAS isn't great, outside the context of a hypermedia.

https://intercoolerjs.org/2016/05/08/hatoeas-is-for-humans.h...

It is, rather, a fairly pointless category error, driven mainly by cargo-cult mentality from the early JSON API era.

Re:SPAs Were a Mistake by unclebucknasty on Wednesday March 02, 2022 @08:25PM (#30535931)
>The problem is the mixing and matching of state management

Routing (history management) is also a big problem (I'm assuming you weren't including that in your definition of "state" here).

Some would say, "but React, etc. have solved the routing issues", and that's perhaps the case. But what's difficult is wiring these routers up outside of a full React app. That is, if you truly want routing "solved", you generally have to go all React (or whatever) or just let the browser handle it in the traditional request/response sense. Sprinkling in just a bit of dynamic interaction wherein you want the history managed is purgatory.

And, on mobile, things get even more interesting. Consider the simple case of popping a modal (especially a slide-out). Many users will hit "back" on a mobile device, which they would reasonably expect to simply close the modal. But, if your app/page doesn't intercede to manage the history, the previous page is loaded instead.

Re:SPAs Were a Mistake by fendy3002 on Wednesday March 02, 2022 @08:34PM (#30535991)
Routing (along with hash path and query string) IMO is definitely a part of state. Different route lead to different content, thus different state.

The problem is which source of truth we want to use. I find that I'll need to refer to routes as the source of truth to process information, meaning "almost" every react action become route-manipulation action and it's state is just derived from the route, which is very similar with what MPA already do.

Re:SPAs Were a Mistake by unclebucknasty on Wednesday March 02, 2022 @09:07PM (#30536237)
Yeah, I think history is definitely a form of state, but didn't seem like the state the parent to my comment had in mind.

And, I do think they're distinct problems (but related) when you're just adding a bit of interactivity to a page or two, as this sub-thread is discussing.

In a full SPA, it's largely coupled and more inline with what you say: let the route drive the action. But, sometimes you have an MPA with a dynamic stateful feature embedded at a particular URL, but which may or may not need a sub-route of its own. In those cases, weird stuff can happen if the history is not managed correctly.

Re:SPAs Were a Mistake by Pensacola on Wednesday March 02, 2022 @06:30PM (#30534960)
> The problem is the mixing and matching of state management.

This. But IMHO the right solution is to make the back-end stateless and manage all client state on the client. Each request authenticates itself, and (if you're ReSTful about it) the back-end is simply a database connector/augmenter.

In this paradigm, the SPA is basically a desktop app that retrieves data from a server, built to run within a framework, which happens to be a web browser.

In case you're jumping to conclusions, know that I'm a late-comer to the SPA party, having resisted from its inception until about a year ago, for all the obvious reasons, including those bemoaned by the OP.

Why did I relent? SPA frameworks like React now handle pretty much all the heavy lifting for you. OP, you should check out React Router, which can render this post's examples irrelevant. I'm surprised that in 2022, someone writing to the web UI layer would bother to create code to manage the address bar when there are a thousand ways to not have to.

Re:SPAs Were a Mistake by catlifeonmars on Wednesday March 02, 2022 @10:49PM (#30536938)
A lot of the arguments against SPAs in TFA center on broken U/X. This is only incidentally related to SPA architecture, and has much more to do with the current SPA ecosystem. IMO it’s more just a lack of standardization and the broken U/X is just an emergent property of the vacuum. MPAs are great because the technology is old and navigation between pages has first class support in all browsers, not because of some intrinsic advantage of the way application state is managed.
Re:SPAs Were a Mistake by unclebucknasty on Wednesday March 02, 2022 @08:28PM (#30535950)
How well does React Router solve these problems if you're not using React fully?
Re:SPAs Were a Mistake by dzhiurgis on Wednesday March 02, 2022 @11:05PM (#30537042)
Any non-trivial app will require some frontend state eventually.
Re:SPAs Were a Mistake by hombre_fatal on Wednesday March 02, 2022 @11:47AM (#30529382)
Exactly. I've been in the position various times where I'm embedding a JS app on a page to help the user do something highly interactive, usually creating/editing content. And then as it's expanding to integrate with other things on the site, I start to wish more of the site was in the JS-app side of things.

Sometimes I realize a SPA would have simply served the user better, and it doesn't necessarily take much to be in that predicament.

Too many people hate on SPAs by, presumably, just imagining static read-only content like blogs and news. Though I'm also a bit tired of "SPAs suck amirite, HN?"

Put the user first, consider the trade-offs that work towards that goal, and see what shakes out.

Re:SPAs Were a Mistake by vlunkr on Wednesday March 02, 2022 @02:18PM (#30531567)
The other thing people who hate SPAs need to think about is that rendering blogs/news/static sites isn't a problem that developers really work on anymore. Businesses will just pick from the huge pile of existing CMSs or hosted solutions because it's easier and cheaper. So if you're wondering why all these developers are building SPAs, it's because we're building custom applications, not blogs.
Re:SPAs Were a Mistake by Closi on Wednesday March 02, 2022 @12:29PM (#30529975)
I think the fundamental issue with SPAs is that it's building on multiple levels of technology that fundamentally weren't designed to support being a single page application.

The browser <-> multiple pages paradigm is pretty much how the web evolved, so SPA's just end up being one giant hack to get everything working.

UWP/WPF/any other desktop app framework demonstrates how easy developing a 'single page application' can be without all the cruft you have to add to make a SPA work because it's actually a sort-of-massive-workaround.

Re:SPAs Were a Mistake by hombre_fatal on Wednesday March 02, 2022 @02:57PM (#30532153)
Well, the browser has certainly evolved past the point of SPAs being nothing but a hack. The browser has evolved into a heavily generalized application environment, as much as we may want to bemoan that. A good web client can surely demonstrate this.

It's certainly true that you don't get to lean on built-in features like history support, but that's why you can now drive history with Javascript. And all sorts of other things. And if you're smart, you're using a solution that handles these things for you.

Rich client development is always hard—on any platform—, and you always make concessions for the platform you're on. I certainly have to when I'm building iOS apps. But I see no reason for this to dissuade you if you can push a better UX to the user.

As tried-and-true as server-rendered architecture might be, there are all sorts of things it will never be able to do no matter how much of a hack you think web client development might be. Software is a hack. And at the end of the day, your users may remain unconvinced when you preach about what the browser was "meant to do" when they begin coveting a richer experience.

That's something that's often left by the wayside when we discuss these things. We talk about technical superiority and become prescriptive about what we think technology is for. While fun thought exercises as craftspeople, we too seldom talk about delivering value. If leaning into the historical nature of the browser supporting HTML pages over the wire helps you build a better experience, that's great. But that's not the only option you have today.

Re:SPAs Were a Mistake by kitsunesoba on Wednesday March 02, 2022 @03:22PM (#30532548)
> Rich client development is always hard—on any platform—, and you always make concessions for the platform you're on. I certainly have to when I'm building iOS apps. But I see no reason for this to dissuade you if you can push a better UX to the user.

I think the difference is how much you as a developer have to "fight" the platform. Having to implement history management yourself very much qualifies as "fighting" to some extent in my eyes… continuing with native platforms as an example, that sort of thing just isn't necessary in most cases – like with iOS, 99% of your "history" management comes for free with some combination of UINavigationController and view controller presentation, assuming the use of UIKit.

Re:SPAs Were a Mistake by hombre_fatal on Thursday March 03, 2022 @09:23PM (#30549864)
As others have said, history management in a SPA tends to be done for you. But if you were to do it yourself, you would centralize your href-click handling in a single spot where you go history.pushState(path) and never bother with it again, it simply hooks into all <a>.

While bad SPAs do this badly just like bad iOS clients do things badly (like incessant spinners, zero caching, and unselectable text), it's a small concesión to make in the scheme of client-side development.

On the other hand, have you ever wrestled with CoreData on iOS? It's like using the worst ORM with the worst Active Record abstraction, easy to get wrong, yet that's the tool you're given. And you're choosing between that built-in solution or going off the rails with another solution with its own trade-offs, and both paths feel like you're wrestling with the platform.

It just comes with the space of client-development, you just tend to get used to wrestling with the platform you have the most experience with, and it's easy to forget that when you judge the concessions that must be made on other platforms.

Re:SPAs Were a Mistake by somishere on Wednesday March 02, 2022 @05:54PM (#30534543)
History management in handled by the browser in SPAs / javascript land too. Apologies if I misread the insinuation here.
Re:SPAs Were a Mistake by jeremyjh on Wednesday March 02, 2022 @06:28PM (#30534936)
It comes for free in mature SPA routing frameworks as well. Who is implementing history management themselves?
Re:SPAs Were a Mistake by emteycz on Wednesday March 02, 2022 @01:05PM (#30530511)
At least since HTML5 and CSS3 and ES6 (so many years already) these technologies are made for SPAs. There aren't many better UI frameworks, and WPF isn't that by a long shot.
Re:SPAs Were a Mistake by Closi on Wednesday March 02, 2022 @06:50PM (#30535179)
I wouldn't really say that - CSS3 was made in 1999 so was hardly made for SPAs.

Additionally HTML5 wasn't really 'made for' SPAs, it added features to HTML which could help support SPA's but it's main design decision was to be 100% backwards compatible with the older HTML spec. HTML5 is made for SPAs the same way that a stretched limo is made for commuting.

Re:SPAs Were a Mistake by emteycz on Wednesday March 02, 2022 @07:27PM (#30535467)
SPAs are old though. Their popularity is modern, but I was making SPAs in 2005 - and it most definitely was a concern of HTML5 and CSS3; it was a concern even before, during the DHTML days. You're right it wasn't the primary concern - that's backwards compatibility, after the XHTML blunder - but that doesn't mean HTML5/CSS3 wasn't made with SPAs in mind.
Re:SPAs Were a Mistake by sitzkrieg on Wednesday March 02, 2022 @02:18PM (#30531572)
ok dont look up how long grid layout has existed in wpf
Re:SPAs Were a Mistake by emteycz on Wednesday March 02, 2022 @02:43PM (#30531920)
Who cares? (I know btw I used to be a C# engineer in my previous life - I actually first used WPF when it was still beta)

Here and now, WPF is much worse. Even Microsoft itself now invests into React Native.

Re:SPAs Were a Mistake by Closi on Wednesday March 02, 2022 @06:40PM (#30535080)
> Even Microsoft itself now invests into React Native.

Microsoft invests in React Native as they want to bring applications built in React Native for iOS and Android to Windows.

The fact they are investing in React Native doesn't necessarily mean much more than the fact that they want developers to compile their React Native apps to Windows as well as the mobile platforms.

Re:SPAs Were a Mistake by int_19h on Thursday March 03, 2022 @01:43AM (#30537903)
WPF hasn't had any serious investments for, what, 10 years, no?

But OP's point still stands - it is much less hacky than anything in the web ecosystem even so.

Re:SPAs Were a Mistake by mananaysiempre on Wednesday March 02, 2022 @04:17PM (#30533293)
I mean, grid layout has existed in Tk (the one with the Motif look) since the earliest version I can quickly find documentation for, 8.2 from August 1999; Wikipedia tells me that 'table', apparently an early version of 'grid', was introduced in July 1993, that is to say around the time Windows NT (and with it Win32) was officially released. (And of course plain Win32 never got it, seemingly because Microsoft decided they weren’t in the business of selling toolkits despite USER being one.)

The hard idea from the programmer’s point of view is automatic layout, not grids; my impression was that Tk originated it (it certainly brought it to light), but now that I’m looking I’m not sure it wasn’t already in Motif to some extent, so the roots of the idea might go down into the primordial soup of Project Athena and similar places.

Re:SPAs Were a Mistake by efdee on Wednesday March 02, 2022 @12:49PM (#30530274)
In my opinion, UWP/WPF/aodaf makes it easy because it just doesn't implement the things a user is used to in a browser (bookmarkability, back button, ...).

If you ignore those things in your SPA, much of the "cruft" is negligible.

Re:SPAs Were a Mistake by kaba0 on Wednesday March 02, 2022 @01:27PM (#30530873)
This is pretty in line with grandparent’s comment in that the browser was simply not made for this - aka SPAs are sort of a hack on the traditional page-based approach.
Re:SPAs Were a Mistake by mike_hearn on Wednesday March 02, 2022 @03:42PM (#30532819)
Many desktop apps have back buttons, and of course mobile apps always have them. They're also more reliable; there is no desktop/mobile equivalent of the "warning: need to re-POST this form" problem.

As for bookmarks, that's semi-right, but the web platform conflates the back button with bookmark-ability in ways that are quite confusing. If you want the back button to get the user out of your settings screen, then you must push a new URL onto the history stack using JavaScript, but then if the user bookmarks your site they'll bookmark the settings screen specifically even though that's very unlikely to be what they wanted. Non-web apps that have enough content to need something like bookmarks often implement a similar mechanism that's more predictable, albeit less general.

The OPs article is really a common lament amongst web developers - they're (ab)using a tool that was never meant for what they're using it for. It's a real and very serious problem in our industry.

The whole SPA vs multi-page dichotomy really emerges because the web doesn't have sufficiently rich, modular or low level APIs. If you look at non-web frameworks like iOS or Java then you get a huge number of APIs (usually classes) tackling the low levels of a problem, then more classes building on the lower levels to give you higher level solutions. Those classes can usually be customized in many different ways, so the amount of control a developer has is enormous. If you start with a high level helper class and find you can't customize it to meet your needs, you can reimplement it using the lower level building blocks.

The web isn't like this. Web APIs are an absolute pigs ear of very high level function calls and classes designed in more or less random ways to quickly hack together a solution to whatever need a browser maker had at the time. HTML5 supports peer-to-peer video streaming and augmented reality but not a virtualized table view. In many cases it's obvious that little or no thought went into the APIs, e.g. XMLHTTPRequest has nothing to do with XML, you can open a URL for a custom URL handler but not detect if that URL will work ahead of time, nor even if opening that URL worked once you try it, and so on. Instead of starting with low level APIs and composing them into high level APIs, browsers start with high level APIs and then introduce entirely orthogonal low level APIs decades later, or never.

These sorts of problems just don't occur when writing desktop apps with professionally designed frameworks - even in the rare cases that you hit some limit of the framework, you can (these days) just patch it directly and ship a fixed version with your app. If you hit a problem in the browser you're just SOL and have to hack around it.

Our industry needs to reinvigorate desktop apps. Attempting to convert browsers into Qt/Java/.NET competitors has:

a. Made HTML5 unimplementable, even by Microsoft. It's not so much a spec anymore as a guide to whatever Chrome happens to do on the day you read it (hopefully).

b. Created tons of security holes.

c. Yielded an atrocious and steadily decaying developer experience.

Re:SPAs Were a Mistake by tracker1 on Wednesday March 02, 2022 @07:05PM (#30535300)
You could just use `history.back()` instead of pushing a new url... beyond this, you may need to listed to history changes so that your UI response... most spa frameworks have a router that supports this without much issue.
Re:SPAs Were a Mistake by michaelchisari on Wednesday March 02, 2022 @03:46PM (#30532873)
Setting limits for future features to keep the code base clean and manageable is something developers could be more vocal about.

Acquiescing to every demand product designers and management throw into the mix is what turns beautiful, easily-maintained codebases into nightmares.

What people are talking about here is writing web apps as a series of small, tightly-coupled spas who manage state within very specific parameters. And that's a great way to build software. Until someone comes in and asks you to draw in the state from one section into two other sections. You have the choice to say a) no and explain why, to b) create a clever "glue" that will be hard to maintain and difficult to explain, or to c) take the time to refactor the code into something more general and complex to allow for the feature on a more abstract level.

Guess which one almost always gets chosen.

The upshot is this: The solution to front-end complexity may not be a technical one, it may not require a new framework or library. It may be a shift in what we expect out of the web. We could always temper our expectations in order to keep our code clean.

Re:SPAs Were a Mistake by themanmaran on Wednesday March 02, 2022 @03:55PM (#30532995)
The end goal of writing code isn't always a "clean and manageable" codebase.

Likewise the solution to SPAs isn't "say no to features".

Re:SPAs Were a Mistake by michaelchisari on Wednesday March 02, 2022 @05:28PM (#30534151)
I'm aware, but the discussion about the failures of spas always center around their failures in maintainable code. So if one's issues with SPAs are codebases becoming unmanageable, the solution won't be technical, it's going to be managerial.

A start would be devs communicating to product & design what the technical limits are to the current approach so that it informs their decisions.

Re:SPAs Were a Mistake by midrus on Saturday March 05, 2022 @01:58AM (#30565076)
> Put the user first, consider the trade-offs that work towards that goal, and see what shakes out.

In my experience, every single team I've been part of that was building an SPA was because they put the developer experience and desires first, even if in the mid/long term the dev experience ends up being worse as the project grows.

Re:SPAs Were a Mistake by 9wzYQbTYsAIc on Wednesday March 02, 2022 @01:18PM (#30530720)
> Exactly. I've been in the position various times

This is why React is such a popular JavaScript framework of libraries.

Re:SPAs Were a Mistake by mattwad on Wednesday March 02, 2022 @12:41PM (#30530151)
I feel like most people that hate SPAs never have to deal with this type of thing, or even only have to work on the backend. They just don't get it. Of course, if you're using a SPA for a static website, you're also doing it wrong but that doesn't mean SPA itself is a bad thing.
Re:SPAs Were a Mistake by zippergz on Wednesday March 02, 2022 @01:06PM (#30530534)
I'm living proof that it is possible to simultaneously hate SPAs and understand why they are popular. I've built and worked on a number of them, I don't have a better alternative to recommend, and yet I still hate them because I think they are a clunky solution to the problem. We need something better, but I'm not smart enough to come up with what that should be.
Re:SPAs Were a Mistake by kitsunesoba on Wednesday March 02, 2022 @03:26PM (#30532611)
I don't think I'm any more smart when it comes to this particular issue, but my thought is that the answer probably has something to do with more primitives that are suited for web applications being provided by web browsers, so it's both easier to build a web app without some huge gangly framework and so frameworks have more to build on top of and less manual footwork introducing room for error.
Re:SPAs Were a Mistake by simonw on Wednesday March 02, 2022 @04:36PM (#30533522)
"They just don't get it"

Believe me, I get it.

I dealt with building these kinds of features for a full decade before SPAs became fashionable.

Now I'm stuck here watching in frustration as people go all-in on SPAs because they didn't know how to solve these problems without them.

Re:SPAs Were a Mistake by somishere on Wednesday March 02, 2022 @06:10PM (#30534727)
I've also been building these things for a number of decades now. That said, I thoroughly enjoy using the various, modern APIs and standards that have come together to enable single page apps. I'm all for first principles, but which stack are you talking about? The "backend" of the web has been about abstraction for a long time now. Building "these kind of features" has become easier and cheaper on any number of fronts.
Re:SPAs Were a Mistake by rosenjcb on Wednesday March 02, 2022 @01:38PM (#30531000)
I agree. These people hating on SPAs are mostly not frontend developers. They're backend devs that think returning an HTML page is all you need to do. Modern websites are very complex.
Re:SPAs Were a Mistake by WillPostForFood on Wednesday March 02, 2022 @02:00PM (#30531307)
Or users who hate watching a whole application load to display some text.
Re:SPAs Were a Mistake by rosenjcb on Wednesday March 02, 2022 @02:18PM (#30531570)
If the only purpose of your site is to load some text or an image, go use a framework with SSG like NextJS. Then you get fast websites without having to pretend that writing stateful updates (e.g. jQuery) to the DOM is fun.
Re:SPAs Were a Mistake by simonw on Wednesday March 02, 2022 @04:33PM (#30533490)
This is what jQuery solved. It made it ridiculously easy (compared to not using jQuery at that time) to add a little sprinkle of progressively enhanced JavaScript to a page. It still works today (and you don't even need jQuery now, as browser standards have mostly caught up), but everyone seems to have forgotten how to do it!
Re:SPAs Were a Mistake by MourningWood on Wednesday March 02, 2022 @04:44PM (#30533613)
teach me :)
Re:SPAs Were a Mistake by thr0wawayf00 on Wednesday March 02, 2022 @11:51AM (#30529441)
This is my biggest gripe with the direction of Rails.

I completely understand the historic reasons for wanting to keep JS to a minimum and stay within ERB/Ruby, but the JS component-driven UI pattern feels like the correct front end architecture for most commercial projects these days, especially now with better JS tools like Svelte, which feels like rails for the front end to me.

I started playing around with InertiaJS recently and I absolutely fell in love with it. I was surprised to see how niche it still is because it's pretty much what I've dreamed what writing JS with Rails could be for the last 5 years.

Re:SPAs Were a Mistake by beaconstudios on Wednesday March 02, 2022 @11:40AM (#30529297)
Progressive enhancement was largely solved before SPAs became a thing. Its quite easy to enhance the client side incrementally, but SPAs started out as useful for full on Web apps and now everybody uses them by default for some reason.
Re:SPAs Were a Mistake by embwbam on Wednesday March 02, 2022 @01:31PM (#30530925)
I agree. I've been thinking about this lately, and have implemented something I think is interesting in Haskell.

https://github.com/seanhess/juniper

It's an implementation of Elm (imagine React if you're a JS dev), but all logic is executed on the server. State is passed back to the server whenever you choose to listen to an event. The view is then re-rendered and virtual dom diffed on the client. Non-interactive pages are just views. If you want them to be interactive, you add a Message an update function.

I used it on a client project and it was pretty delightful.

It probably isn't documented well enough yet to make total sense, but I think it's a step in the right direction.

Re:SPAs Were a Mistake by ysavir on Wednesday March 02, 2022 @01:12PM (#30530626)
> Then you add a couple of client-side Stimulus controllers, maybe a Turbo frame here and there and it works fine, but then you get to browser navigation and you're screwed, because none of this works out of the box if somebody were to submit the form, then navigate back. Now you have to implement lifecycle handling to account for navigation and once you're done, you've basically implemented a SPA, except it's broken into a mix of tightly-coupled Javascript, Ruby and ERB templates.

Where in this process did you need to start adding navigation via JS? Did that functionality really require JS, or was it implemented that way just because other parts are JS, and the trend was continued? Could you have used Stimulus controllers to manage functionality on the page itself, but when it came time to navigate to a new page, just done a basic browser redirect?

Saying that SPAs is a mistake doesn't mean that a strong dependence on JS or frameworks in a mistake. It just means that trying to make an entire site fit into a single page load introduces more costs than savings. You can still have pages controlled via React or Vue or Stimulus, but forgoing the router functionality.

In my own apps, I use Vue and VueX to control page behaviors, but each URL is its own Rails page. For example, I have a search page that uses Vue and VueX to asynchronously load, filter, and display search results. Clicking on a result is a basic browser redirect, taking you to the result's page, doing a full Rails page load, and again using Vue and VueX to manage any dynamic state (any static content is rendered via ERB files).

This has created a very clear and simple structure that allows each page to have any dynamic functionality it needs, but no complications from having to maintain navigation or browser history via JS. The browser already does that natively, and I get to spend my time working only on actual features--not recreating the browser's built-in functionality, or debugging my own take on it.

Re:SPAs Were a Mistake by Zanfa on Wednesday March 02, 2022 @01:25PM (#30530832)
> Where in this process did you need to start adding navigation via JS? Did that functionality really require JS, or was it implemented that way just because other parts are JS, and the trend was continued? Could you have used Stimulus controllers to manage functionality on the page itself, but when it came time to navigate to a new page, just done a basic browser redirect?

In my specific example, the navigation itself didn't happen through JS, but you need to hook into navigation APIs to handle backing into a partially-filled form after submitting to rebuild the UI to reflect the state before the user hit submit. To make things even more fun, Turbo/Stimulus (sometimes?) breaks bfcache in Safari & Firefox so they behave different from Chrome.

Personally, I detest the vast majority of SPAs, especially the ones from Google, Facebook and Linkedin. Not even sure what they do to make them so horribly slow to use.

Re:SPAs Were a Mistake by timr on Wednesday March 02, 2022 @01:36PM (#30530981)
> In my specific example, the navigation itself didn't happen through JS, but you need to hook into navigation APIs to handle backing into a partially-filled form after submitting to rebuild the UI to reflect the state before the user hit submit.

I'm not sure I understand. The "conventional" solution to this is not to do it -- the reason browsers don't re-fill submitted forms is to prevent duplication. Give users the ability to post-backclick-repost and your DB will rapidly fill up with duplicate rows.

If you do need to back-navigate to a page that has been submitted (say, to edit the submission w/o requiring an edit-specific URL), you have the server re-render the form with the filled values.

If that isn't sufficient, you can always push your form state on the history stack using the history API, so even though this is a bad idea (IMO), you can still do it pretty easily without needing to resort to re-writing nav.

I hate to say it, but I feel like a lot of this stuff had server-side solutions that worked fine circa 2010, but have been almost completely forgotten.

Re:SPAs Were a Mistake by fuzzy2 on Wednesday March 02, 2022 @02:42PM (#30531913)
But browsers absolutely do keep the form filled unless your HTML or JS says otherwise. Pressing back after submitting on a vanilla HTML form keeps all values in place. As it should.
Re:SPAs Were a Mistake by timr on Wednesday March 02, 2022 @03:54PM (#30532985)
Not after a post. If you change the form method to get, I believe this is the behavior.

There are tons of good reasons to prefer this behavior, aside from just avoiding duplicates. Think of login forms.

Re:SPAs Were a Mistake by fuzzy2 on Wednesday March 02, 2022 @04:16PM (#30533280)
Yes, even after POST. Why not try it, right here, on Hacker News. The comment form uses POST. I post this comment and go back and my text is still in the input box.

In fact, browsers even have re-submit built-in: Just press F5 on a page that was retrieved using POST. That’s why so many sites use a redirect after POST.

Re:SPAs Were a Mistake by timr on Wednesday March 02, 2022 @05:03PM (#30533834)
Redirect after POST was a pattern created to bypass the warnings that (most) browsers emit on back-navigating after form submit, while still preventing double-submit (by redirecting to the GET):

https://www.theserverside.com/news/1365146/Redirect-After-Po...

It sounds like this warn-on-double-submit behavior is convention and not required, so maybe it has become more common for browsers to stop doing it.

> Why not try it, right here, on Hacker News.

OK, I did. HN does a 302 redirect on comment POST to the comment GET. When you back nav, you are seeing the response to a GET request to /reply?id=X

(In other words, the form is re-rendered.)

Edit: oddly, however, submitting on form rendered by GET /reply?id=X ends up creating a new comment, so that's just weird server logic. It might explain why you occasionally see duplicate comments on HN.

Edit 2: on backnav to a comment edit, the redirect is to GET /edit?id=X, which is a re-render of the edit form, the process I described in my OP. Not sure what's going on with the back-after-post...maybe a bug?

Re:SPAs Were a Mistake by fuzzy2 on Wednesday March 02, 2022 @05:17PM (#30534011)
> When you back nav, you are seeing the response to a GET request to /reply?id=BLAH

With the text you previously entered, which the browser restored. If it did not for you, you have non-standard settings like disabled caching. I can assure you that it behaves the same on Firefox for Linux, Windows, macOS and Safari on iOS: go back, form content is restored.

In fact, the entire internet is full of people trying to get rid of this behavior.

Re:SPAs Were a Mistake by timr on Wednesday March 02, 2022 @08:14PM (#30535852)
I don't have non-standard browser settings. I watched the form submit in the debugger. It responds with a 302 to the GET request.
Re:SPAs Were a Mistake by ysavir on Wednesday March 02, 2022 @01:43PM (#30531075)
Thanks for sharing! That helps me understand things better.

> you need to hook into navigation APIs to handle backing into a partially-filled form after submitting to rebuild the UI to reflect the state before the user hit submit

Was this a hard requirement for the feature or just a nice-to-have? I understand why you'd want that behavior ideally, but it also seems the sort of thing that adds much additional complexity for a problem that isn't (at least in my eyes) severe. Having people re-fill things isn't too much of an ask, I think, and if it's something crucial, it might be better served with a preview page that allows additional changes. Or a "Make changes" link that redirects to a page that can load from the submitted state. There are easier ways to handle it than manually controlling navigation.

But yeah. If the behavior is a hard requirement from the business/product side of things, then using an SPA is no longer an architectural decision made for technological purposes, but is a feature requirement from beyond. And that's a whole different matter.

Re:SPAs Were a Mistake by Zanfa on Wednesday March 02, 2022 @02:15PM (#30531530)
A little bit of both probably. Supporting it when navigating back is probably a nice-to-have, but persisting file upload previews etc through a form submit that might fail due to some unrelated ActiveRecord validation (maybe a blank field) is a must.
Re:SPAs Were a Mistake by pier25 on Wednesday March 02, 2022 @05:42PM (#30534387)
I think the best solution for this is just doing fullstack dev with SSR + partial hydration.

The issue is that, so far, we haven't figured out how to have a good fullstack DX.

Remix is probably one of the best attempts so far, but it still leans heavily towards being a very sophisticated renderer for the front end. The proof is you probably would not use Remix to create a 100% backend project with no front end. Same with SvelteKit or Next.

Until fullstack frameworks get more serious about the backend, we will be in this weird limbo.

In my current project I use Fastify as my main backend framework, and then use Svelte for SSR + hydration. I loose a lot of the frontend sophistication that SvelteKit brings to the table, but OTOH I have an amazing backend framework and total control and flexibility.

Re:SPAs Were a Mistake by mdoms on Wednesday March 02, 2022 @01:38PM (#30531004)
At the risk of a pile on, this is what jQuery was brilliant for. And frankly the native browser APIs have caught up enough that scenarios like what you want to achieve are simple to implement with just a script tag and a sprinkling of JS. I don't know what "Stimulus controllers" or "Turbo frames" are but they don't sound necessary.
Re:SPAs Were a Mistake by specialp on Wednesday March 02, 2022 @01:48PM (#30531144)
Yes. Nobody should have to make a SPA to accomplish what JQuery did with sprinklings of JavaScript. JQuery was maligned because many people used it to make all XHR requests all over the place resulting in non-deterministic async behavior. JQuery was made to make adding small bits of JS easy and work in almost all browsers.

Bringing in React and turning that non-deterministic events firing all over the place greatly improved that situation, but this has become if someone needs JS, bring in SPA framework. This is in spite of the browser world getting much better. So just as JQuery was used to make SPAs to bad effect, SPA frameworks have been used to do minimal JS actions in a bad way.

Re:SPAs Were a Mistake by te_chris on Wednesday March 02, 2022 @11:53AM (#30529476)
Phoenix LiveView really does solve a lot of these problems.
Re:SPAs Were a Mistake by jeremyjh on Wednesday March 02, 2022 @06:35PM (#30535015)
It does and it has lots of work-alikes on other platforms (though some are not nearly as good). For almost any app that is inherently useless when not connected to the server, its a pretty good fit.
Re:SPAs Were a Mistake by ordinaryradical on Wednesday March 02, 2022 @12:58PM (#30530402)
I was just going to say this sounds like a great example of something that Elixir, LiveView, plus maybe a little Alpine.js could handle...
Re:SPAs Were a Mistake by alskdjflaskjdhf on Wednesday March 02, 2022 @01:58PM (#30531287)
Inertia [1] is an interesting project in this space that might solve some of your problems. I haven't used it, but I believe the general goal is to make it easy to "plug in" client-side frameworks (React, Vue, Svelte) into server-side views.

[1] https://inertiajs.com/

Re:SPAs Were a Mistake by CPLX on Wednesday March 02, 2022 @12:55PM (#30530358)
Yeah can someone fix this please. I'm experiencing the same thing with a rails app I'm currently building.

In all seriousness it feels like there must be an elegant way to do more responsive modern functions while keeping the core server rendering concept. It's 2022 after all. But no I don't know a good solution either.

Re:SPAs Were a Mistake by adfm on Wednesday March 02, 2022 @12:59PM (#30530424)
HTMX lets you update the url with hx-push-url=“true”
Re:SPAs Were a Mistake by xwdv on Wednesday March 02, 2022 @12:27PM (#30529956)
This problem you described is exactly why SPAs will continue to dominate over the traditional server rendered websites.

Often when I see people arguing against SPAs, they are peddling trivial toy websites that don’t do much and don’t change much.

When you need to build a serious application on the web with quickly growing feature sets and complex state management, just use a SPA. It’s 2022.

Re:SPAs Were a Mistake by jmconfuzeus on Wednesday March 02, 2022 @02:50PM (#30532026)
The Basecamp guys created Hey which is a mail app not implemented as a SPA. It's probably the fastest mail app I've ever seen while delivering around 40kb of javascript.

If Hey is a toy app you then you must be working on some truly alien projects from the future or something.

Re:SPAs Were a Mistake by enra on Wednesday March 02, 2022 @11:51PM (#30537288)
While it might be fast, it feels you’re like using Rails app with turbo links. Page loads. Feels barely interactive.

Compare native Mail app and Hey. If anything should be a SPA, it’s an email app.

Also who cares how much kb of JavaScript your mail app uses? It’s completely wrong metric to optimize for an app someone uses every day, multiple times a day and likely has the app open all the time.

(Also haven’t heard people using Hey much since the launch)

Re:SPAs Were a Mistake by boomlinde on Thursday March 03, 2022 @03:02AM (#30538373)
SPAs dominate? Off the top of my head I can't think of a single SPA that I actually use regularly. I worked in a niche a few years back where they seemed common (configuration interfaces for embedded systems) but looking at my own habits and the sites that dominate in terms of web traffic, that's thankfully not something that has caught on generally.

I can sort of see the point if the "A" part of "SPA" actually applies to your product, but for the dominant players that doesn't seem to be the case.

Re:SPAs Were a Mistake by rk06 on Wednesday March 02, 2022 @12:03PM (#30529626)
for simple cases, you can use alpine.js, petite-vue etc. However, if you are considering "routing", then it is no longer a "little bit".
Re:SPAs Were a Mistake by pvorb on Wednesday March 02, 2022 @04:37PM (#30533533)
Did you have a look at https://htmx.org/ ? I think it solves the "just a tiny bit of interactivity on an MPA" kind of thing.
Re:SPAs Were a Mistake by kaba0 on Wednesday March 02, 2022 @01:25PM (#30530839)
It was probably never too beautiful of a technique, but JSF does solve this problem splendidly. You basically have a view-flow besides the usual ones and it can act in many of the ways SPAs can.
Re:SPAs Were a Mistake by jmconfuzeus on Wednesday March 02, 2022 @02:30PM (#30531735)
Progress bars and previews are simply a matter of attaching an events to the http request and file input respectively.

When someone submits a form and navigates back, don't you just re-display the empty form?

If it needs to be a form bounded with the uploaded file (maybe as part of a wizard), then why not ask the server for it instead of storing client side state?

Maybe using Javascript without a SPA looks hard because you're trying to avoid storing state on the server as well as bypass native browser features.

Re:SPAs Were a Mistake by camjw on Wednesday March 02, 2022 @05:07PM (#30533876)
I feel like react-rails (https://github.com/reactjs/react-rails) is basically perfect for this. You just make the photo upload its own react component and render it as normal from your rails view. You basically encapsulate the small bit of complex state into a component and it doesn't infect the rest of your app with SPA.
Re:SPAs Were a Mistake by garyrob on Wednesday March 02, 2022 @01:09PM (#30530578)
"I think one of the unsolved problems of client-side interactivity on websites is how difficult it is to add it just a little bit of extra client-side functionality to a traditional server rendered website. " I've started using django-unicorn lately and I'm hopeful that it may solve that problem for many use-cases.
Re:SPAs Were a Mistake by amelius on Wednesday March 02, 2022 @01:22PM (#30530787)
Yes. The fitness of an architecture can be partially measured by looking at the cost of feature updates.