Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Create an SPA with React using WordPress REST API

Notifications You must be signed in to change notification settings

gregrickaby/React-WordPress-API-Demo

Repository files navigation

React WordPress REST API Demo

Netlify Status

Create an single page app using the WordPress REST API and Create React App.

NOTE: This repo is dated, and needs to be refactored to use React Hooks.

https://react-wordpress-api-demo.netlify.app/

Development

Clone the repo:

git clone git@github.com:gregrickaby/React-WordPress-API-Demo.git

Install dependencies:

cd React-WordPress-API-Demo && yarn

Start dev server:

yarn start

Build a production ready app:

yarn build

FAQ

I don't see posts

It's because your web broswer is blocking CORS. Disable tracking protection in Firefox and/or any ad blockers.

I want to use my WordPress REST-API endpoint

  1. Open /src/config.js
  2. Change wordPressURL to match your website
  options: {
    wordPressUrl: "https://YOUR-WORDPRESS-WEBSITE-URL/wp-json/wp/v2/posts",
  },
  1. Run yarn start or yarn build to view your data

Built with Create React App, WordPress, and hosted on Netlify