
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@devloco/create-react-wptheme-test
Advanced tools
Create React WP themes with no build configuration.
UPDATED to support Create React App v3.1.1
The intention of this project is to maintain a set of custom react-scripts that will allow you to
create React WordPress themes as easily as create-react-app allows other devs to create their apps.
The biggest difference with this project and the original is that it uses your WordPress server as the development server instead of the Webpack Dev Server.
Michael Soriano is writing a tutorial for creating a theme using React. He uses create-react-wptheme for the initial setup. He provides a lot more detail than this readme and the screen shots are really helpful.
Check it out:
Let's build a WordPress theme with React: Part 1 (Setup)
For more details check out the rest of this document.
To create a WordPress theme using the create-react-wptheme, follow these steps.
cd C:\xampp\htdocs\wordpress\wp-content\themescd /xampp/htdocs/wordpress/wp-content/themesnpx create-react-wptheme to make a new theme
npx create-react-wptheme my_react_theme
npx create-react-wptheme my_react_theme --typescriptcd my_react_theme/react-srcnpm run start<your theme folder name>/index.phpPlease restart the Nodejs watcher now...npm run start and rerun that same command again.When new versions of Create React WP Theme are released, you can upgrade an existing theme using a single command.
From within your theme's react-src folder, run this command at a command prompt:
npm install @devloco/react-scripts-wptheme@latest
If your theme uses TypeScript, you'll need to run a second command (create-react-wptheme uses the Types from Facebook's React-Scripts):
npm install react-scripts@latest
Important note for Yarn users: be sure to use yarn add instead of npm install in the above commands.
If you're looking at a React tutorial on the web, you can use create-react-wptheme in place of create-react-app.
But you do have to remember that the React app code is one extra folder down inside your theme folder.
Notice that the final folder in this path is react-src:
/xampp/htdocs/wordpress/wp-content/themes/<Your-Create-React-WP-Theme-Folder>/react-src
So for example, if the tutorial instructs you to edit the src/App.js file, then for you, that file would actually be located at:
<Your-Create-React-WP-Theme-Folder>/react-src/src/App.js
The authors of the original create-react-app say that using the "Public" folder (found at react-src/public in your new theme's folder) is a last ditch "escape hatch" for adding otherwise-hard-to-deal-with files.
But for this project, I've decided to use it for all things that you'd put into a normal WordPress theme (e.g. functions.php, etc.). So any PHP, hard-coded CSS, and/or hard-coded JS (like other JS libraries that you'd like to reference globally (I don't judge)), can go into the public folder.
In addition, any changes made to CSS, JS, and PHP files in the Public folder will cause a rebuild to happen. Which is unlike create-react-app which ignores most of the files in the Public folder.
After you've created a new theme, and all the setup is done, you'll find a file named react-src/user.dev.json that has some configuration options that you can mess with if you need to.
If you develop using SSL (i.e. HTTPS), then you might want to run the Browser Refresh Server under SSL as well. Especially if you use Firefox, see here: Firefox Websocket security issue.
To configure the Browser Refresh Server to use SSL, follow these steps:
create-react-wptheme, change directory into the react-src folder in your theme's folder
cd C:\xampp\htdocs\wordpress\wp-content\themes\<your theme's folder name>\react-srccd /xampp/htdocs/wordpress/wp-content/themes/<your theme's folder name>/react-srcmkdir sslssl folder
cd ssl.pem extension, or each file has a different extension like .crt and .key.user.dev.json in the folder named react-src in your theme.
"wpThemeServer": { "enable": true, "host": "127.0.0.1", "port": 8090, "sslCert": "ssl/localhost.crt", "sslKey": "ssl/localhost.key", "watchFile": "../index.php" },sslCert and sslKey items. Make sure the values point to your SSL certificate and key files.react-src folder (as shown above).host to 127.0.0.1 instead of "localhost". The numeric address gets special treatment at the OS level as being mostly safe.react-src folder.
cd ..npm run startuser.dev.json above.
127.0.0.1 and port 8090 as shown above, then open your browser to:
Browser Refresh Server.While you're actively developing your theme, the files are not optimized for production. Before you put your theme into production, you need to run the build command.
Open a command prompt and change into the react-src folder of you theme and run this command:
npm run build
When that command finishes, your optimized files are located in a folder that can be deployed to your production server.
Here's an example showing which folder to deploy to your server:
<- deploy this folder to your production server's themes folderIf you need to continue developing your theme, simply:
cd react-srcnpm run startAnd all your theme files will reappear.
The react-src/user.prod.json configuration file is read when you run npm run build. The only option in there is setting the "homepage"
which controls the relative linking to files in your theme. The "homepage" setting in your main package.json file is used during development (and build by default).
During development, this is probably what you want. But if you know your production server has a different root, then you can set the homepage to be different during a production build.
For example:
"homepage": "/wordpress/wp-content/themes/<your theme's folder name>"/wordpress part, so set the "homepage" line in your user.prod.json file to:
"homepage": "/wp-content/themes/<your theme's folder name>"npm run buildcreate-react-appreact-scripts as little as possible.
I'm grateful to the authors of existing related projects for their ideas and collaboration:
The original.
I used this as an example for writing my own plugin for watching changes to the create-react-app "public" folder.
Create React WP Theme is open source software licensed as MIT.
FAQs
Create React WP themes with no build configuration.
We found that @devloco/create-react-wptheme-test demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.