Please post support requests on https://wordpress.org/support/plugin/reactpress/.
Why React and WordPress
With WordPress you get:
- easy content management for help pages, your landing page, your blog, and your other marketing activities
- secure and proven user management
- over 100.000 plugins
- a lot of flexibility over time to change the character of your site
For example, if we want to write a new revolutionary email app, we can write the interface of the email client with React, but for everything else use WordPress. So while you’re developing your app, you might want to:
- choose and install a theme
- create a landing page for your app
- add a form to collect email addresses
- create a blog and publish your posts on Twitter to promote your app
- optimize your site for search engines
Later it might be useful to
- offer a paid membership
- create a forum or FAQ
- create separate landing pages
- all this can easily be done with WordPress, without writing a single line of code.
Embedding a React app into WordPress with ReactPress
While there are other ways to integrate React with WordPress, the ReactPress plugin is the easiest to embed a React app into a WordPress page and lets you use create-react-app without any custom build configurations.
Not only does ReactPress automate the React integration for you, but it also ensures a seamless development experience, by running your local React dev server with the theme of your WordPress site.
Why not just use headless WordPress with SSR?
I know that headless WordPress with Next.js, Gatsby, or Frontity is all the rage right now, but with these solutions, you add a layer of complexity to your app, and more importantly, you lose a lot of the benefits of the WordPress ecosystem (themes and plugins).
The steps from development to deployment are:
- Setup your local dev environment.
- Install ReactPress on your local WordPress installation
- Create a new React app
- Develop your React app
- Build the app
- Install ReactPress on the live WordPress site
- Create the same React app there
- Upload the build of your React app to your live site to deploy it.
Repeat steps 3, 4, and 7 until your app is finished.
Setup your local dev environment.
To develop React apps your WordPress installations need access to:
- and a POSIX-compatible system (Windows support is experimental)
Install ReactPress on your local WordPress installation
In your local WordPress, go to plugin installation, search for ReactPress, install and activate the plugin.
Create a new React app
To create a new app from the command line, open a terminal and navigate to the
apps directory of the ReactPress plugin.
npx create-react-app [your-app-name] in the
Then go to the ReactPress page in your WordPress admin. If you already opened the ReactPress page before, reload it.
You then will see the new app in the admin. Next, choose a URL Slug for your app. This will create a new page with the given slug. Make sure the slug you select is not taken by any other page/post of your site.
Go back to your console, start the React app with
npm start or
yarn start. Your React app should be running with the styles of your WordPress site.
Develop your React app
Build the app
If you want to deploy to your live site, build your app from the command line with
Install ReactPress on the live WordPress site
Before you upload your React app, install ReactPress on your live site, like on your local installation.
Create the same app folder there
Create the same React app folder on your live system, that you created on your local system. Important! Use the exact same directory name as on your development server.
Upload the build of your React app to your live site to deploy it.
Finally, upload the build of your React app. Upload the build folder of your local React app to the app on your live system.
The ReactPress admin shows where your apps are located. It will be something like this:
If you click on the URL slug of your React app in ReactPress you should see your React app on your live system.
Where to go from here?
You should be able to create React app embedded in WordPress now. If you have the next big app idea you are ready to start.
If you have any questions, let me know in the comments.