Contact
Site: US UK AU |
Nexcess Blog

Using WordPress As Your Front-End Application’s Content API

April 9, 2018 0 Comments RSS Feed

Most content websites use a content management system like WordPress to generate web pages on the server before sending them to the browser. There are advantages to this approach: generating pages on the server asks little of the web browser; the business logic of the application is located in one place, rather than spread across the server and the client; and search engine crawlers are well-equipped to deal with HTML: even modern crawlers may have problems with Single Page Applications (SPAs).

Nevertheless, SPAs and other applications in which the view layer and much of the logic are handled on the client have become increasingly popular. JavaScript is more capable and more pleasant to work with than it once was. View frameworks like React and Vue make the creation of fast client-side applications a breeze for skilled developers. Browser APIs have advanced to the point at which they’re capable of supporting web applications every bit as feature-rich as native applications; in fact, technologies like Electron, which is based on the Chromium browser, are being used to develop “native” applications with web technologies.

It’s against that background that WordPress released its REST API, predicting that the future of WordPress depends on its ability to serve content to rich applications that run mainly in the browser. But the question remains, why would we want to abandon the traditional server-side rendering offered by classic WordPress and embrace the idea of API driven content sites?

JavaScript Can Be Fast

We often think of JavaScript as slowing the web down. It’s to blame for bloating web pages with countless and trackers and unnecessary features. There’s some truth to this: a JavaScript-driven content site will lead to larger downloads when a user first visits, but most of the initial content can be cached by the browser. The big performance benefits come as the user is navigating around the site.

A well-architected front-end application can download and cache content in the background. A visitor lands on your site’s home page, and once the application is loaded, it starts downloading the article content before the user clicks on anything. When they do click on something, that content is available in an instant, displayed without so much as a page refresh.

Offline Functionality

Technology like Service Workers allow web applications to cache content and intercept browser requests. They can run the application even when there is no web connection. Although the user won’t be able to download new content, they will be able to use the application and access content that has already been cached.

Multiple Front-Ends

The WordPress REST API presents a uniform interface that can be interacted with by any authenticated client, including mobile applications, other content management systems, analytics platforms, and so on.

React, the popular front-end framework from Facebook, includes React Native, which can be used to build native applications for iOS and Android devices that share code with the web application.

Users Benefit from the Content Management Power of WordPress

WordPress is ubiquitous, it’s free, and it’s easy to use. Many years of development have been invested into making WordPress a fantastic content management platform for sites of all sizes. Writers, editors, and developers are familiar with it. The API means that content publishers can embrace a tried and true technology without having to forgo modern app development workflows and technologies.

Posted in: Nexcess