September 28, 2017

Choosing A React Alternative For Your WordPress Themes And Plugins

Photo by qimono on Pixabay

Matt Mullenweg recently announced that the WordPress project will no longer use the phenomenally popular React framework in its projects. React was being used to build the forthcoming Gutenberg editor, which will now have to be rewritten.

WordPress theme and plugin developers don’t have to follow the lead of the WordPress project. They can use whichever front-end technology they like to interact with the WordPress REST API, but if you are embarking on a new WordPress plugin or theme, it’s worth knowing about the alternatives — and there are a lot of alternatives.

If you’re interested in why WordPress is moving away from React, I discussed the nitty-gritty in an earlier post, so I won’t go into detail here. Suffice it to say that Facebook, which develops React, releases the code under a license that doesn’t sit well with many open source developers.

I’ll have a look at three alternatives to React later in this post, but the way we choose a framework is at least as interesting as the framework we choose. I’ll suggest three principles that might be useful to you:

  • Choose a framework your developer already knows.
  • Choose a framework the community is invested in.
  • Unless you have a compelling reason to move away from React, don’t.

The goal is to build things. Any of the major contenders in this space is adequate to that task. If you or the developer you hire is already familiar with a framework, there’s no real reason to switch (unless it’s so obscure you won’t be able to find anyone to maintain the code).

At the time of writing, the WordPress community hadn’t settled on a React alternative. When it does, developers will start pumping out code. They’ll ask and answer questions on Stack Exchange and WordPress developer forums. They’ll write demo themes and plugins. In short, whichever framework the community decides on is a good bet for developers.

If you have already invested in writing lots of React code for your project, think long and hard before you decide to move to a different framework or library. React is awesome: that’s why it’s so popular. Some organizations, including WordPress, have specific problems with the license. If you don’t think those problems are relevant to you, there’s no real need to change.

So, what are the alternatives to React? It really depends what you mean by “alternatives”. React uses the Virtual Dom, it mixes CSS and HTML with Javascript, and it’s a view framework, not a full MVC like some of the competition. Other front-end frameworks make different choices. Depending on your needs, you might choose from Vue, Preact, Angular, Mithril, Aurelia, Glimmer, Elm, and many more.

I’m not a betting man, but Vue is by far the most popular of the React alternatives, and it would be an obvious choice. Indeed, it seems that the WordPress folks have been in conversation with Vue’s developers. The transition from React to Vue may not be smooth sailing because the underlying principles are different (no JSX-type shenanigans), but Vue is a solid choice.

Preact is a lightweight alternative to React that, unlike Vue, uses the same API. It’s very easy to transition from React to Preact, and there is a compatibility layer that allows developers to use React code with the Preact framework. If you’re looking for a direct replacement for React, you won’t go far wrong with Preact.

Finally, Elm is a completely different kettle of fish — it’s not even Javascript. Elm is a functional programming language for building web applications that compiles to Javascript. If that sounds interesting, check out this proof-of-concept WordPress theme from Jack Lenox.

Nexcess
Nexcess

Nexcess, the premium hosting provider for WordPress, WooCommerce, and Magento, is optimized for your hosting needs. Nexcess provides a managed hosting infrastructure, curated tools, and a team of experts that make it easy to build, manage, and grow your business online. Serving SMBs and the designers, developers, and agencies who create for them, Nexcess has provided fully managed, high-performance cloud solutions for more than 22 years.


We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.