React Router for WordPress is a plugin that allows you to use React applications directly in your WordPress frontend and backend.
This plugin enables seamless integration of React applications within your WordPress environment, providing flexibility for both frontend and backend development.
- Upload the plugin files to the
/wp-content/plugins/
directory, or install the plugin through the WordPress plugins screen directly. - Activate the plugin through the 'Plugins' screen in WordPress.
We recommend using this plugin in a local development environment first before building your application for production.
- Open the
src
folder and locateApp.js
. This is the entry point of your application. - Use any React or WordPress React code in this file.
- For frontend-only styles, use the
editor.scss
file. - For styles that apply to both frontend and backend, use
style.scss
.
npm run build
: Build the applicationnpm run start
: Start the development servernpm run hot-start
: Start the hot reload server. This will open a localhost with your application and watch for changes.
Note: If hot-start doesn't work, modify gulpfile.js
and set the correct URL of your local WordPress site in the siteUrl
variable. You may also need to remove the port option.
Simply open the WordPress editor and add the React Router block. This will render your React application on the page.
Q: How do I add a React app to a page? A: Open the WordPress editor and add the React Router block. This will render your React application on the page.
- Initial release
- Contributors: The WordPress Contributors
- Tags: block
- Tested up to: 6.6
- Stable tag: 0.1.0
- License: GPL-2.0-or-later
- License URI: https://www.gnu.org/licenses/gpl-2.0.html