Start WordPress Plugin Development with React JS Package in just few steps

Overview

React Js & Wordpress Plugin Package

Start WordPress Plugin Development with React JS Package in just few steps

Getting Started with this Setup

  • Clone the repository inside of your wp-content/plugins directory
  • Rename the cloned plugin directory, wp-vue-plugin.php
  • Navigate to the plugin directory and run
    npm install
    npm start
  • Activate plugin

Create Your Own Setup

Step 1: Composer Setup
  • Inside plugins directory Create a folder. Run command to install PHP autoload setup composer init
  • Step 2: NPM Setup - wp script
  • Setup simple npm environment by running npm init
  • Step 3: Install @wordpress/scripts
  • Install @wordpress/scripts npm library in dev environment npm install @wordpress/scripts --save-dev
  • Step 4: Add this code to Package json file
  • Add this code to Package json file
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "build": "wp-scripts build",     
        "start": "wp-scripts start"
      }, 
    
  • Step 5: Create New File webpack.config.js
  • now create new file - webpack.config.js to add React and ReactDOM as external dependency.
      const defaults = require('@wordpress/scripts/config/webpack.config');
    
       module.exports = {
         ...defaults,
         externals: {
           react: 'React',
           'react-dom': 'ReactDOM',
         },
       }; 
    
  • Step 6: Add code main php file
  • Add id="app" to loading react component main PHP File;
    also add this style & script

    wp_enqueue_style( 'app-style', plugin_dir_url( FILE ) . 'build/index.css' );

    wp_enqueue_script( 'app-script', plugin_dir_url( FILE ) . 'build/index.js', array( '' ), '1.0.0', true );

  • Step 7: Add React index file
  • Create a file index.js inside /src folder - src/index.js
     import { render } from '@wordpress/element';
    
     const App = () => {
         return (
             

    React Wordpress App


    ); } render(, document.getElementById('app'));
  • You might also like...
    Laravel Admin Dashboard, Admin Template with Frontend Template, for scalable Laravel projects. It is to save your time when You start with new scalable Laravel projects with many features Bootstrap, cooreui, infyom admin Generator, roles and  permissions, translatable models, spatie media and much more Initial template to start your awesome Laravel, Tailwind and Vue projects
    Initial template to start your awesome Laravel, Tailwind and Vue projects

    Features Laravel 8.* Tailwind 2.1 Ready and Loaded @tailwindcss/typography @tailwindcss/forms Dark mode ready All variants enabled by default Vue 2, V

    Quick Start - Project With Laravel 8.x and AdminLTE 3

    Quick Start - Project With Laravel 8.x and AdminLTE 3 (feat. Docker) Cursos de Laravel - PT-BR Step by step Clone this Repository git clone https://gi

    Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application

    Slim Framework 4 Skeleton Application Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application. This app

    Easily start new projects using FukigenMedia's starterpack.
    Easily start new projects using FukigenMedia's starterpack.

    Fukigen Filament Starterpack Easily start new projects using FukigenMedia's starterpack. Usually, many of us are confused about where to start a new p

    Laravel Quick-Start - a boilerplate for Laravel Application with typical packages preinstalled and configured

    Laravel Quickstart is a boilerplate for Laravel Application with typical packages preinstalled and configured to extend a full-fledged application. We tried to make it as minimal as possible.

    A simple and clean boilerplate to start a new SPA project with authentication and more features from fortify
    A simple and clean boilerplate to start a new SPA project with authentication and more features from fortify

    A simple and clean boilerplate to start a new SPA project with authentication and more features from fortify. Its like the little sister of Jetstream, but as SPA.

    Kick-start you next Laravel based API with this awesome boilerplate 🚀
    Kick-start you next Laravel based API with this awesome boilerplate 🚀

    Laravel API boilerplate 🚀 An awesome boilerplate for your next Laravel 9 based API. It's only goal is to simply kick-start your API development and p

    Start your application with Hamtaro.

    Hamtaro framework About Technologies Controllers Components Commands Front-end development Getting Started About Hamtaro is the new web framework for

    Owner
    Devang Vachheta
    Wordpress Developer @POSIMYTH Innovations
    Devang Vachheta
    Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps !

    ?? CRUDBOOSTER - Laravel CRUD Generator Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps ! About CR

    Crocodic Studio 1.7k Jan 8, 2023
    🔪 WordPress + React Starter Kit: Spin up a WordPress-powered React app in one step

    Postlight's Headless WordPress + React Starter Kit is an automated toolset that will spin up three things: A WordPress backend that serves its data vi

    Postlight 4.3k Jan 8, 2023
    WP React Plugin Boilerplate - WordPress Setting via React and Rest API

    WP React Plugin Boilerplate is a starter WordPress plugin to develop WordPress Plugin via React and Rest API. WP React Plugin Boilerplate WP React Plu

    Santosh Kunwar 36 Dec 6, 2022
    Laravel 8 + React + Typescript + React Router v4 + Hot Module Reloading

    Laravel React Typescript Boilerplate An opinionated boilerplate based on Laravel 8.*, React 16 and Typescript empowering you to get off the ground qui

    George Cameron 56 Dec 16, 2022
    A Laravel REST API backend with React/Redux, hot module reloading in development and route-level code splitting

    React Laravel Boilerplate This is the boilerplate that I personally use for getting projects off the ground quickly using my favourite stack of techno

    Carwyn Stephen 174 Jan 6, 2023
    ⚡️ This package provides a wonderful PHP skeleton to start building your next package idea.

    This package provides a wonderful PHP Skeleton to start building your next package idea. Requires PHP 8.0+ ⚡️ Create your package using Composer: comp

    Nuno Maduro 383 Dec 20, 2022
    Kick-start laravel prepared package for you!

    Laravel Platform Install For development composer install npm install npm run dev ?? npm run prod php artisan migrate --seed For testing composer ins

    Nejc 6 Sep 16, 2022
    :computer: :octocat: A hackathon/MVP boilerplate for laravel web applications. Start your hackathons without hassle.

    Laravel Hackathon Starter - SUSUMU 進 If you have attended any hackathons in the past, then you know how much time it takes to get a project started: d

    Prosper Otemuyiwa 1.6k Dec 17, 2022
    Start a new Laravel 8 project with the AdminLTE template installed.

    AdminLTE template Laravel 8 package Start a new Laravel 8 project with the AdminLTE template installed. Installation Create database. Clone repository

    Mairo Rodrigues 12 Dec 21, 2022
    Opinionated way to start a new Laravel project.

    Laravel Boilerplate The way I start new Laravel projects. Why? I just got tired of repeating the same things over and over. I made this repository pub

    Benjamin Crozat 0 Mar 18, 2022