Yeh... and if you've got iOS and Android covered, then web is a different thing. Doesn't need to be an SPA, can still use those same APIs if that makes sense for your app
I had always assumed that the move to Spa's occurred in large part due to mobile apps. A mobile app effectively has to be a client rendering of data from an API, and if you have to do that for mobile, it makes sense to do it for the Web.
Also if you're careful with design then the JSON API that the SPA uses can be re-used for iOS / Android apps and third party integrations as you scale.
My point is rather if you are doing that (a hybrid app) wouldn’t doing a full spa actually be simpler? And allow you to use a less complex framework / a framework which doesn’t have to support that legacy.
Indeed, that's true. While I'm not saying they're good for everything, one thing I like about SPAs is that the server can just serve up an API that is usable by both web and mobile clients. No duplication of templating/view logic between server and client as often happens when the server is serving up HTML.
For a lot of things you don't need an app. A responsive website, maybe with some PWA features, is good enough. Building and maintaining a separate API and a mobile app is a huge amount of work.
The pendulum is swinging back from building everything as an SPA to a mix of server-rendered and client side content. It will probably overcorrect as things tend to do in software but the trend makes sense.
What you're asking is advantages of SPAs over classic web apps.
For example you write only one REST API for all clients: iOS, Android, Web.
They can use the same endpoints.
Otherwise you need to write separate controllers/views for web templates, which leads to duplication.
Even if you develop capabilities API-first, you don't need an SPA, though. You can create some backend code that consumes your API and in turn serves separate web pages to a front end.
One topic I haven’t seen discussed yet is that an SPA style web app doesn’t just have JSON-API endpoints for itself but also for external systems, like an iOS app. When using HTMX or similar systems you’d have to create 2 end points for a certain bit of functionality: one that sends HTML and another that sends JSON.
I've been thinking about this a lot, and the one thing I love about SPAs is that everything the user can do from the front end. They can do from the API. The trend has essentially tricked tons of corporate apps into opening up APIs to their users. My screen scraping skills are starting to get rusty, but it's worth it.
I sometimes daydream about a framework that allows me to build a spa and a server side app at the same time using the same url scheme.
well, given that everything is made for the web, it seems like it would be pretty straightforward to jam most existing SPA webapps into something like this.
SPAs don't solve data exchange problems. Json and xml API's do.
You can have a templated html multipage site that still has a Json or xml api for other UI's that need it like android or ios. SPAs just try to morph html into some kinda more responsive dynamic app at the cost of complexity and initial load times.
reply