Use WordPress as the headless CMS of your single-page application

Shakil Ahmed
1 min readAug 15, 2018

JavaScript has experienced a revolution in recent years. The demand for JavaScript powered client-side rendered single page applications is more than ever. WordPress was traditionally used for serving static HTML pages rendered by the server. However, its adaptation of the REST API has made it a suitable candidate as the data source of your client-side app. There are very few developers who don’t know their way around WordPress and it has a very modern, easy-to-use dashboard. I’m going to show in simple steps how to use WordPress as your data source.

The posts and the custom posts of your WP site are automatically available via REST API. For example, if you want to fetch your latest posts, send a request to http://yourdomain.com/wp-json/wp/v2/posts. Almost all data related to your contents is available via REST API. A detailed list of the routes can be found here.

If you are fetching data via REST API and want the contents to be unavailable on the main WordPress site to avoid duplicate contents, install this plugin. This plugin will make all other pages of your main WordPress site unavailable and leave only the WordPress dashboard and the REST API for use.

--

--