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

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.

--

--

--

Software Developer. Building digital products.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shakil Ahmed

Shakil Ahmed

Software Developer. Building digital products.

More from Medium

How to host a react app to netlify from Github Pages.

Code a blog with Sanity.io and Next.js

code a blog in next.js and Sanity as a CMS by Sabir Hussain

[Tip For Developer] Surfing the website that needs custom-host without manually customizing the…

Is Nodejs Still Relevant For Your Startup in 2022?