Skip to content

MarcoJmz/wp-into-react

Repository files navigation

WP Into React

A WordPress theme boilerplate to quickly hook a React app in WordPress frontend.

Description

This theme serves as a starting point for developers who want to build React applications that integrate with WordPress. It provides the minimum required WordPress theme files along with a React setup using @wordpress/scripts.

Getting Started

Installation

  1. Clone this repository or download it to your WordPress themes directory (wp-content/themes/)
  2. Navigate to the theme directory in your terminal
  3. Run npm install to install dependencies
  4. Run npm start for development mode
  5. Run npm run build for production build
  6. Activate the theme in WordPress admin

Development

  • React code lives in the src directory
  • The entry point for the React application is src/index.js
  • Edit src/App.js to start building your React application
  • WordPress theme files are in the root directory (style.css, index.php, functions.php, etc.)

Available Scripts

  • npm start - Starts the development task
  • npm run build - Creates a production build
  • npm run format - Formats code with Prettier
  • npm run lint:css - Lints CSS files
  • npm run lint:js - Lints JavaScript files

Features

  • React integration with WordPress
  • Automatic WordPress REST API integration
  • Modern JavaScript tooling with @wordpress/scripts
  • Basic theme structure following WordPress standards

WordPress Integration

The theme provides a data bridge between WordPress and React through the wpIntoReactData global JavaScript object which includes:

  • REST API URL
  • Security nonce for REST API authentication
  • Site name
  • Site URL

Use this data to make authenticated API requests to WordPress from your React app.

License

This theme is licensed under the GPL-2.0-or-later license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors