I just read the article Why I hate your Single Page App on Medium. As a long time React and AngularJS developer I understand some of his points. Building a SPA is not easy as it seems. It provides a some of advantages in User experience but it also requires a lot of effort to make it works properly.

Here are some reasons make people dislike SPA:

  • Too many SPA framework to choose and each framework has its own ecosystem that you have to evaluate carefully.
  • It takes more efforts to make UX smoothly.
  • It requires more developers to build. Your backend developer can build SPA but they won’t and never make it properly (this opinion comes from my experience when I have to work with backend developer).
  • You have to think carefully about the app structure.
  • Most of SPAs are not SEO friendly and unless you implement server-side rendering and it’s not a trivial thing.

But SPA also provides a lot of benefit for End-User:

  • Faster loading time. SPA only has to lot the initial scripts, after that it can send Ajax request to ask for more data and update the user interface. Tradition website has to reload the whole things after every clicks.
  • Your app responses better. When user do any action, the app is updated instantly. In some cases, you have to implement a spinner to help user understand that they app has responded to their action.
  • Your frontend is separated from backend thus easier to maintain the app.
  • Better development experience frontend developer.

The question comes down to when and where to use SPA.

If your website is really simple, for example: you just need to display news and information and you need SEO to increase visit so you don’t need SPA and a WordPress website is enough. When created my blog, I was thinking about using React or WordPress and I choose WordPress because my blog is pretty simple. I just need to install a theme and my blog ready to use.

About SPA, ask yourself this question: What was the last time that you used Gmail classic (the slow version of gmail)? Every clicks is expensive, right. It takes few seconds to reload the whole website. Switching between tabs and compose new email is much easier on the modern Gmail. Ask the same question for Facebook, Spotify, Netflix, Messenger…

So if your website have a lot of interactions, SPA is a great choice. For example, a POS app. Do you want to make it as a traditional website. Reloading the whole app after every click, really?

There are a lot of application for SPA: chat app, CRM, online file manager, travel planning… so you have to use the right tool for the job ;). It’s 2017 and the tools for building SPA have been improved. Personally, I enjoy developing apps with React and AngularJS. Here are few things that make me love React:

  • Everything you see on screen are components. Components are easy to develop and maintain.
  • You can prevent CSS conflict issue with some style libraries like StyledComponent or CSSModules.
  • Hot reloading helps you update your app without even reload your app.
  • GraphQL is a game-changer for data fetching, I believe it will replace REST.
  • Javascript has been growth a lot in recently years. ES6 and ES7 helps developer more productivity (Babel transforms your code to ES5 and your code can run on most of popular browsers)

Next time, if someone tells you that they have SPA, please show them some great examples of SPA like Gmail. Even better, ask them what kind of application they are going to build and tell them whether they should use SPA or not.