TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why use an SPA?

22 pointsby abahloover 5 years ago
Using a single page application like React has become the defacto standard for most web applications. I realize this makes sense for JavaScript-heavy, interactive components but it feels like a majority would work perfectly fine with server-side templates, maybe even better since it’s way less overhead (talk about translations, validation, sync of backend routes and frontend client, etc.).

10 comments

factorialboyover 5 years ago
I agree. In fact static rendering has become refreshing given the saturation of SPAs everywhere. Even content websites are SPAs these days. Pointless.<p>Anyway my next venture will be as JS free as possible. I don&#x27;t have JS, I love it. But that tribe is going thru an over-engineering cycle. Just like Java in the early 2000s.<p>It will all settle down, eventually.
评论 #21671123 未加载
tonyover 5 years ago
Downsides first: It&#x27;s a time sink. By the time you bootstrap webpack, babel, sass, etc. you&#x27;re often pushed into building an &quot;app&quot; and instead of a web page. So there&#x27;s a sunk cost just to do something remotely meaningful with react, in practice. The build outputs are colossal, even with tree shaking and codesplitting. The initial build times on a non-trivial app can be minutes. Minutes.<p>I made some pretty scathing comments about React &#x2F; SPA apps on HN before. I was insistent I could build an app with django templates + css + js. But in the end I ended up having to use webpack just to build SASS&#x2F;JS, even if I spurned using a SPA app. So I never found a way to keep it with just jinja&#x2F;django templates and css and ship a good experience.<p>If you&#x27;re making a website that&#x27;s differentiated enough to be noticed, most likely it&#x27;ll end up needing the attention to detail a JS app brings. It&#x27;s just hard to make UX scale without it: template includes are not composable - ES Modules + React components definitely are.<p>What changed my mind on SPA:<p>- TypeScript is really the thing that changed the game, because it shores up a very hard-to-scale, disorganized language ecosystem with an amazing type system.<p>- Webpack and babel getting somewhat stable in their APIs, as well as their extension&#x2F;plugins<p>- React Functional Components &#x2F; Hooks (cleans up a level of indentation and avoids that class cobwebs that can make maintenance a pain)<p>- Prettier: Excellent formatting tool<p>- JSX: Ends up making components very &quot;HTML-like&quot; and the formatting with prettier makes it feel like &quot;blocks&quot; where you can get a gist of the depth&#x2F;hierarchy.<p>- GraphQL + Relay: The responses are code-generated into types and it automates retrieving data from the server. You can throw redux out. Which leads me to another thing - I consider redux an antipattern on most cases. Not fun at all to work with at scale.<p>I wish typescript &#x2F; react &#x2F; jsx &#x2F; sass just worked from the browser itself, without all the webpack and babel, and these configuration files. I think maybe, after thousands of hours, I finally comprehend webpack. But in all likelihood I&#x27;m mistaken, and webpack 5.x will end up making me have to start over anyway.
BWStearnsover 5 years ago
If your team consists of backend engineers who haven’t done full stack in a while and front end engineers who are already good with react&#x2F;vue then I’ve found it easier to just go SPA instead of everyone trying to remember how Django&#x2F;Rails works. Also if your server side stuff has to or probably will have to talk to other machines then you’re just saving yourself the trouble of implementing the human only version.<p>If your team consists of mostly people who’re used to doing rails&#x2F;Django style webapps then it’s perfectly reasonable to not build an SPA.
macandoover 5 years ago
Why do we need elaborated backend structures? A bit of SQL in stored procedures on top of a DB is good enough all the time. It&#x27;s way less overhead. Heck, why don&#x27;t we just let the users get what they want by giving them access to a SQL prompt. We could eliminate the UI completely.
评论 #21675566 未加载
评论 #21667301 未加载
aphextronover 5 years ago
The web has evolved from a collection of hyperlinked documents in the 90s to a fully featured application platform in 2019. There&#x27;s still a place for server side rendering. But it&#x27;s for static content, not applications anymore. Practically everyone on the web now has a client capable of executing complex application code. As a result it has become incredibly simple for developers to build things out on the client that would have been impossible with the old paradigm. Not only does it make development faster, but it allows a much greater separation of concerns across the stack. Backends can now be completely agnostic of the presentation layer, which pays for itself many times over when you realize a given application may be running across native desktop, native mobile, mobile web, desktop web, TV OS&#x27;s, game consoles, etc. Having to duplicate your business logic for these use cases would be terrible.
dmlittleover 5 years ago
A valid use-case is to provide a UI for API products (Stripe, Lob, Twilio, etc). The main product is an API for customers to use but you may also want to be able to login to their website and check the current state of affairs of your account. Since you already have to build an API for your customers and everything you&#x27;re showing might already be possible with the API, you can create a UI to glue the request calls together. A SPA can use the same API, avoids you having to write new code for your website and you get to dog-food your own API.<p>Disclaimer: I work for Lob.
评论 #21666299 未加载
tobltobsover 5 years ago
Shiny New Thing Syndrome.
muzaniover 5 years ago
For example, one of our web apps regularly sends &#x27;heartbeats&#x27; to the server. It&#x27;s difficult to track this across different pages.<p>But there&#x27;s definitely overhead, so I wouldn&#x27;t do it unless necessary.
jklein11over 5 years ago
In a lot of cases, it is more efficient to save state on the front end so you don&#x27;t need to retrieve it each time on the back end.
stephenrover 5 years ago
The #1 use for an SPA is called “resume padding”.<p>If you’re a front end dev who wants to look important, making the entire application reliant on your fragile client side code can give a lot of hutzpah to your resume.
评论 #21672293 未加载