GithubHelp home page GithubHelp logo

nicksrandall / headless-wp-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from postlight/headless-wp-starter

0.0 2.0 0.0 2.96 MB

๐Ÿ”ช WordPress + React Starter kit

Home Page: https://trackchanges.postlight.com/introducing-postlights-wordpress-react-starter-kit-a61e2633c48c

License: GNU General Public License v2.0

PHP 77.45% JavaScript 16.39% CSS 6.08% Shell 0.07%

headless-wp-starter's Introduction

WordPress + React Starter Kit

Postlight's Headless WordPress + React Starter Kit is an automated toolset that will spin up two things:

  1. A WordPress backend that serves its data via the WP REST API.
  2. A server-side rendered React frontend using Next.js.

You can read all about it in this handy introduction.

What's inside:

  • An automated installer script which bootstraps a core WordPress installation.
  • The WordPress plugins you need to set up custom post types and custom fields (Advanced Custom Fields Pro and Custom Post Type UI).
  • Plugins which expose those custom fields and WordPress menus in the WP REST API (ACF to WP API and WP-REST-API V2 Menus).
  • All the starter WordPress theme code and settings headless requires, including pretty permalinks, CORS Allow-Origin headers, and useful logging functions for easy debugging.
  • A mechanism for easily importing data from an existing WordPress installation anywhere on the web using WP Migrate DB Pro and its accompanying plugins (license required).
  • A starter frontend React app powered by Next.js.
  • A Docker container and scripts to manage it, for easily running the frontend React app locally or deploying it to any hosting provider with Docker support.

Let's get started.

WordPress Backend

Before you install WordPress, make sure you have all the required software installed for your operating system.

Prerequisites

  • OS X: You'll need Homebrew and Yarn installed.
  • Windows: To install under Windows you need to be running the 64-bit version of Windows 10 Anniversary Update or later (build 1607+). The Linux Subsystem for Windows should be installed and enabled before proceeding. Then, you'll need the prerequisites for Ubuntu Linux, detailed below, set up.
  • Ubuntu Linux: You'll need the latest version of NodeJS, Yarn and debconf-utils installed first. Follow this simple guide to get the latest version of NodeJS installed. Install the rest of the packages using the apt-get package manager. Note: During the WordPress installation, you may be asked to enter the root password at the prompt due to the use of the sudo command

Install

The following command will get WordPress running locally on your machine, along with the WordPress plugins you'll need to create and serve custom data via the WP REST API.

> yarn install && yarn start

When the installation process completes successfully:

Import Data (Optional)

To import data and media from a live WordPress installation, you can use the Migrate DB Pro plugin, which is already installed. To do so, in the robo.yml file, set the plugin license and source install. Run robo wordpress:setup, then run robo wordpress:import to pull in the data.

Extend the WordPress API

At this point you can start setting up custom fields in the WordPress admin, and if necessary, creating custom REST API endpoints in the Postlight Headless WordPress Starter theme. The primary theme code is located in wordpress/wp-content/themes/postlight-headless-wp. As you modify the theme code, be sure to use WordPress coding standards.

React Frontend

To spin up the frontend client app, run the following commands:

> cd frontend && yarn install && yarn run dev

The Next.js app will be running on http://localhost:3000.

Docker

Most WordPress hosts don't also host Node applications, so when it's time to go live, you will need to find a hosting service for the frontend.

That's why we've packaged the frontend app in a Docker container, which can be deployed to a hosting provider with Docker support like Amazon Web Services or Google Cloud Platform. For a fast, easier alternative, check out Now.

To run the Docker container locally:

  1. Install Docker on your computer.
  2. In frontend/config.js, replace localhost:8080 with your publicly-accessible WordPress installation's domain name or IP address.
  3. Start the container by running this command:
> yarn run deploy

Made with โค๏ธ by Postlight. Happy coding!

headless-wp-starter's People

Contributors

ajshapell avatar alexmanno avatar george-haddad avatar ginatrapani avatar kevboh avatar lex111 avatar tylerbarnes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.