Live data from Hacker News

If Not SPAs, What?

macwright.com

41–50 of 456 posts

Re: If Not SPAs, What?

#41
post #8

I think Phoenix Live View is maybe the most compelling story around this ( https://github.com/phoenixframework/phoenix_live_view ). I'm moving a side-project from React/SPA to Phoenix live view and it's kind of amazing to get the dev ergonomics of a server-rendered page with the UX benefits of a SPA. This course is a pretty great intro: https://pragmaticstudio.com/phoenix-liveview

I started this course and the animations/presentation are amazing. some really clear explanations. But the fake cute-sy dialogue and the extra fluff that says how wonderful and amazing and great and FUN liveview is means I didn't get past the first video

Re: If Not SPAs, What?

#42

I used Turbolinks for the first time on a new Rails app about 2 years ago and was floored by the impact - it felt like a SPA in terms of no page loads and overall speed. I'm convinced that this is the solution for the majority of use-cases, combined with selective usage of either React components or something like Stimulus where you need more sophisticated UI components.

Is there an equivalent of Turbolinks for something like Django? Or even for MVC PHP apps?

If you're a Laravel user you'll want to look into Inertia.js[1].

[1] https://inertiajs.com/

Re: If Not SPAs, What?

#43

Our app ( https://domestica.app/login ) is a pretty good (IMO) example of a blazing fast SPA. It uses Mithril and copious amounts of chunking to make the bundle size extremely small.

This page breaks the back button on mobile safari and Firefox

Re: If Not SPAs, What?

#44
The hydrogen client for matrix.org (1) has an interesting approach using vanilla JavaScript and indexeddb.

From a previous this week in matrix(2): "Hydrogen tries to be the lightest Element. It is written entirely in vanilla javascript (no React, no Webpack) for complete control, structured as an MVVM app, leveraging the raw performance of indexeddb."

(1) https://github.com/vector-im/hydrogen-web (2)https://matrix.org/blog/2020/08/14/this-week-in-matrix-2020-...

Re: If Not SPAs, What?

#45
One entry in this space that doesn't get a lot of attention is ASP.NET Blazor [1]. Blazor gives you the option of writing views in C# that will actually compile to WebAssembly and run in the browser, or run on the server and send DOM updates over a SignalR connection, a lot like LiveView.

[1] https://docs.microsoft.com/en-us/aspnet/core/blazor/

Re: If Not SPAs, What?

#46
post #8

I think Phoenix Live View is maybe the most compelling story around this ( https://github.com/phoenixframework/phoenix_live_view ). I'm moving a side-project from React/SPA to Phoenix live view and it's kind of amazing to get the dev ergonomics of a server-rendered page with the UX benefits of a SPA. This course is a pretty great intro: https://pragmaticstudio.com/phoenix-liveview

I started this course and the animations/presentation are amazing. some really clear explanations. But the fake cute-sy dialogue and the extra fluff that says how wonderful and amazing and great and FUN liveview is means I didn't get past the first video

Having deployed liveview for an admin dashboard, I gotta say, it really is great FUN, and no-fuss, even if you're slinging together a system that customers never see so you don't care if the code gets a bit knotty, and your datastructures are abjectly awful.

Re: If Not SPAs, What?

#47
I guess it's still targeting the client-side SPA case, but I think Svelte[0] is worth a shoutout for taking a different approach than React/Vue/Angular/etc. The Svelte "framework" is really just a compiler that produces a small bundle of vanilla JS that updates the DOM directly (no virtual DOM).

[0] https://svelte.dev/

Re: If Not SPAs, What?

#48

Earlier quoted context omitted.

This is great, thank you for sharing. We primarily test in Chrome which doesn't seem to display this for whatever reason. Should be an easy fix to remove the history for the loading page.

For what it's worth, the same happens in my Chrome. (Maybe you're logged in and don't get the behavior because of that?)

Should be fixed now if you want to try again :)

Re: If Not SPAs, What?

#49
post #2

If you can do server side great: do it. The difficulty is accurately predicting how much JavaScript you'll end up writing. If your client-side JavaScript is comparable in complexity to your SSR you'll eventually end up with the worst of both worlds.

Is it really that difficult?

If a client tells me what they want built, I bet I'd be able to roughly guess how much js there's going to be, probably within a few hundred lines for a, say, 3 month project.

The larger the project, the large the margin of error, but still, it's really not that hard for the vast majority of work we do. Or at least I do, e-commerce, enterprise apps, etc.

Re: If Not SPAs, What?

#50
I've had great success with the Turbolinks + Stimulus approach. There are a couple of common patterns that you'll reach for, namely, lazy loading content (basically a with a URL attribute that you have Stimulus load via AJAX) and really leaning into Rails remote-link / server javascript responses for modals and little page updates.

It's so great to still be super productive and be able to crank out several pages of an app in a few hours vs most of the React / SPA codebases where you might send the whole day on one little component.

Post reply on HN