How to build a SAAS application with WordPress

WordPress used to be called a blogging platform. Then it become the #1 CMS. Then people well it’s good for typical smaller scale sites, but you need something more specialized for ecommerce. Then WordPress and WooCommerce become the most common ecommerce platform. Today the question is, can WordPress compete as a framework for application development? More specifically, is WP a good platform for running a SAAS (Software as a Service) application?

The naysayers will obviously say no. You must use NodeJS, PHP is too… slow/old << insert incorrect adjective here. What about the loading pattern and performance, isn’t WordPress “bloated”? What about the front-end, are we really going to run a SAAS using jQuery and PHP/HTML templates?

Let’s quickly toss aside the misinformation about what WP is and isn’t as a prospective SAAS platform:

  1. PHP is a stable and (since PHP7) fast language. It has a few disadvantages compared to NodeJS for certain types of applications (where the NodeJS features like multi-threading might be useful). However, like Java, PHP will be powering much of the web for at least 20 more years. It’s place is solid, just like WordPress. It’s not going anywhere. It’s ease to learn and it’s suitability to web apps continues to be strong favorable points. Also compared to JS, it has a more solid object-oriented structure that helps serve in complex API development.
  2. WordPress bloat is real. Except it isn’t. Let’s explain. The vast majority of what is described as bloat comes from the use of plugins and themes. In other words WP core is very lightweight, super optimized. Loading a blank page out of WP takes milliseconds even on a weak server. So when people talk about WP performance, their talking about 3rd party themes and plugins that often add substantial scripts. In particular themes that try to be and do everything, loading dozens of scripts and providing a complex DOM structure, this is the most obvious cause of slowness in WP sites. None of this is relevant when talking about running a SAAS, because you will definitely use a custom theme and that means control over all DOM output, and that means no 3rd party scripts. A SAAS running on WP can use 3rd party plugins (which could contribute to performance problems), but obviously as a developer you have to take responsibility for analyzing all code that goes into your app whether it’s library code (such as PHP Composer projects) or 3rd party WordPress plugins. Generally speaking, a SAAS running on WordPress will only use a plugin if it’s very high quality optimized code, and only if using it is the best choice. Developers will usually lean towards building 100% of the plugins they install in a SAAS application unless there is an overwhelming advantage to running something off-shelf.
  3. Modern JS in the front-end like React or Vue do have real and obvious benefits over PHP/HTML templates, jQuery and other older front-end methods. The WordPress ecosystem is playing catch-up in this area. But that doesn’t stop you from building your entire WP front-end as a React app (or using another modern JS system). React in particular is now natively supported (embedded) into WordPress. There are also WP Script tooling from NPM to help with the build processes. Over the years to come expect to see more an more React-powered WP themes, React-powered WP Admin UX’s, and yes, more and more WP/React SAAS applications. React is our choice (at SaberWP) for front-end framework, but we also see many projects taking place that use Vue and other libraries.

How WP can power a SAAS

Like with many technical topics, sometimes there are too many options. It often takes a lot of projects where different developers and companies try different methods before it becomes clearer what works and what doesn’t. We’re still in the earlier stages of that with using WordPress to power SAAS systems. Key questions remain like should we use WP multisite or not? How do we handle user access controls? How can we leverage Gutenberg as a block editor in a non-post context? This article won’t answer all these questions… but here are some parts to the puzzle that we believe are useful to know.

Leveraging the WP REST API in the SAAS

WP made two big moves forward in recent years, one was the adoption of React/Gutenberg, and the other was providing custom REST API support. The former got more attention in most circles. It’s also more commonly leveraged so far. When it comes to SAAS, both those initiatives are important, but it’s the REST API that is the game-changing leap. Although most WP plugins continue to use their internal PHP API for most operations, the shift is beginning to occur where even within your own application code, you call the REST API endpoints. This has a range of sometimes subtle advantages. Not the least of which is that your automatically creating a complete API-driven system, and this means good things for adoption and integration with other apps and services. But it also has benefits in terms of code structure and code automation. The consistently of a REST API provides a solid base for an app to leverage particularly as it scales. It’s a way of maintaining simplicity in an app that could become too big and complex if it didn’t have a solid way of enforcing separation of concerns.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *