Member-only story

WordPress | Beginner-friendly WordPress plugin development using React JS

Raviya Technical
3 min readJul 22, 2023

--

WordPress | Beginner-friendly WordPress plugin development using React JS

Setup of an npm project using cmd

npm init

Install the WordPress official package of scripts.

npm install @wordpress/scripts --save-dev

Change in package json

{
"name": "tools",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@wordpress/scripts": "^26.9.0"
}
}

Create a file called webpack.config.js.

const defaults = require('@wordpress/scripts/config/webpack.config');

module.exports = {
...defaults,
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
};

Create a template and create the file name app.php (Path: templates/app.php).

<div id="raviya">
<h2>Loading...</h2>
</div>

Create a project folder file with the name as project : tools.php

<?php

/**
* The plugin bootstrap file
*
* Tools plugin
*
* @link https://github.com/bhargavraviya
* @since 0.0.1
* @package…

--

--

Responses (2)