Example at http://paloma.sedeau.com/wordpress_decoupled/
Using Wordpress as a Decoupled / Headless CMS is not the easiest solution, nor is it the most logical one. Services such as Contentful or Built.io do that just fine.
However, if you want, if you really really want, to use Wordpress, or if you just want to avoid using a SaaS, and to benefit from an open source project and keep your data on your own server, it might be for you.
This project is just a test giving an example of what a decoupled CMS can look like, using Wordpress (for the CMS part) REST API, ReactJS and Flux.
It was highly inspired by Ustwo incredible work : https://github.com/ustwo/ustwo.com-frontend
Some documentation about the Wordpress Rest API : https://developer.wordpress.org/rest-api/ https://developer.wordpress.com/docs/api/
webpack, webpack-dev-server and Babel
React, react-router-dom and Flux
Eslint and eslint-plugin-react
Jest tests
I recommand creating an empty theme making a redirection to your decoupled front-end directory. Just create a theme with an index.php file in it, containing this line :
<?php header( "Location: http://www.yourdomainlinkingtoyourfrontendbuild.com"); ?>
Locate the config.sample.js
in your_front_directory_path/app
, copy and rename it config.js
and change the path to your own.
To launch a development server :
$ yarn install
$ yarn start
or
$ npm install
$ npm start
To get a production build :
$ yarn build
or
$ npm build
To run tests :
$ yarn test
or
$ npm test