A WordPress theme boilerplate to quickly hook a React app in WordPress frontend.
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.
- Clone this repository or download it to your WordPress themes directory (
wp-content/themes/) - Navigate to the theme directory in your terminal
- Run
npm installto install dependencies - Run
npm startfor development mode - Run
npm run buildfor production build - Activate the theme in WordPress admin
- React code lives in the
srcdirectory - The entry point for the React application is
src/index.js - Edit
src/App.jsto start building your React application - WordPress theme files are in the root directory (style.css, index.php, functions.php, etc.)
npm start- Starts the development tasknpm run build- Creates a production buildnpm run format- Formats code with Prettiernpm run lint:css- Lints CSS filesnpm run lint:js- Lints JavaScript files
- React integration with WordPress
- Automatic WordPress REST API integration
- Modern JavaScript tooling with @wordpress/scripts
- Basic theme structure following WordPress standards
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.
This theme is licensed under the GPL-2.0-or-later license.