React inside WordPress: Extend your existing website using React-based Web Components

J Hinter
5 min readFeb 2, 2020

In this article, I’m going to show you how to create a Web Component. Our widget will be based on React and can be seamlessly integrated into any website and CMS, like WordPress, with only two lines of code! 💪

Best of both worlds: React (frontend framework) and WordPress (CMS)

Prerequisites: You should have some basic understanding of React with TypeScript and web development in general. To follow this tutorial, please check out my demo project bonus-calculator on GitHub. 📌

Why? React inside WordPress

I love using WordPress for what it’s made for: serving static websites and managing content. Special requirements can mostly be met using plugins and visual editors like Elementor. In some cases, however, you need the flexibility of a custom-made widget with your own styles, behavior, and user flow. I’m talking of small, informational calculators and wizards not requiring any backend, like this tutorial’s demo project.

Demo project: Bonus Calculator Widget
I’m running a website promoting P2P investment platforms. Most of these platforms have cashback offers for new customers. Your cashback usually dependends on your initial investment. There’s a fixed (e. g. 5$) and variable component to it (e. g. 2% of your initial investment).
We’re going to create a web component, which…

--

--