WordPress Plugin
The FlatWP React Companion plugin brings modern administration to WordPress with a beautiful React dashboard.
Overview
FlatWP React Companion is a modern WordPress plugin that connects your WordPress site to Next.js. It features a React-based admin dashboard for easy management, automatic cache updates, and seamless content synchronization.
Key Features
Modern React Dashboard
Beautiful, responsive admin interface built with React:
- Real-time monitoring - See connection status and statistics live
- Cache management - Control Next.js cache from WordPress
- Activity logs - Track all plugin activities
- Settings management - Configure everything in one place
- Auto-refresh - Dashboard updates every 30 seconds
Automatic Cache Updates
Content changes in WordPress automatically update your Next.js site:
What triggers updates:
- Publishing or updating posts/pages
- Changing featured images
- Updating custom fields (ACF)
- Deleting content
How it works:
- You save content in WordPress
- Plugin detects the change instantly
- Sends update signal to Next.js
- Your website shows new content automatically
- No manual refresh needed!
Preview Mode
Preview drafts and scheduled posts before publishing:
- Secure preview links
- Time-limited access
- See exactly how content will look
- No need to publish to preview
ACF Integration
Automatic registration of flexible content blocks:
- 8 content block types ready to use
- 2 sidebar widget types
- Page settings meta box
- All exposed via GraphQL automatically
Installation
Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
- Node.js 18+ (for building the React app)
- WPGraphQL plugin
Step 1: Install WPGraphQL
- Go to Plugins → Add New
- Search for "WPGraphQL"
- Click Install Now, then Activate
Step 2: Install FlatWP Plugin
Option A: Upload ZIP (Recommended)
- Download
flatwp-react-plugin.zipfrom GitHub Releases - Go to Plugins → Add New → Upload Plugin
- Choose the ZIP file
- Click Install Now
Option B: Manual Install
- Extract the ZIP file
- Upload the
flatwp-reactfolder to/wp-content/plugins/ - Go to Plugins in WordPress admin
- Find "FlatWP React Companion" and click Activate
Step 3: Build the React App
The plugin includes React source code that needs to be built:
# SSH into your WordPress server or use local terminal
cd /path/to/wp-content/plugins/flatwp-react/admin-react
# Install dependencies (first time only)
npm install
# Build the React app
npm run build
This creates a dist/ folder with the compiled dashboard.
Step 4: Configure Plugin
- In WordPress, go to the new FlatWP menu item (lightning bolt icon)
- Click on Settings
- Enter your configuration:
Next.js Site URL: http://localhost:3000
(or your production URL like https://yourbrand.com)
Revalidation Secret: [generate a secure random string]
(must match REVALIDATION_SECRET in your Next.js .env.local)
Preview Secret: [generate another secure random string]
(must match PREVIEW_SECRET in your Next.js .env.local)
Generate secrets:
openssl rand -base64 32
- Check Enable Webhooks
- Click Save Settings
Step 5: Test Connection
- Go to FlatWP → Dashboard
- Look for the connection status indicator
- It should show a green checkmark if connected
- You'll see live statistics about your site
Dashboard Features
Overview Tab
The main dashboard shows:
- Connection Status - Is Next.js connected?
- Content Statistics - Posts, pages, and draft counts
- System Information - PHP version, WordPress version, plugin status
- Quick Actions - Common tasks at your fingertips
Cache Management
Control your Next.js cache:
- View cache statistics
- Clear cache manually
- See recent cache operations
- Monitor cache performance
Settings
Configure all plugin options:
- Next.js connection settings
- Revalidation preferences
- Preview mode options
- ACF field configuration
Activity Logs
Track everything the plugin does:
- Content updates
- Cache revalidation events
- Preview requests
- Error logs
Using the Plugin
Publishing Content
When you publish or update content:
- Edit your post/page in WordPress
- Click Update or Publish
- Plugin automatically notifies Next.js
- Changes appear on your site within seconds
- Check the dashboard to see the activity
Previewing Drafts
To preview content before publishing:
- Create or edit a draft post/page
- Click the Preview button (standard WordPress button)
- Opens your Next.js site with the draft content
- Share the preview URL with others if needed
Managing ACF Blocks
The plugin automatically provides ACF fields:
- Edit any page
- Scroll down to Page Builder
- Click Add Content Block
- Choose from 8 block types
- Fill in the fields
- Publish - the blocks appear automatically on your Next.js site
Troubleshooting
Dashboard Not Loading
Problem: White screen or "Loading..." never finishes
Solutions:
- Check that React app is built:
cd wp-content/plugins/flatwp-react/admin-react
ls dist/ - If
dist/doesn't exist, run:npm install
npm run build - Clear WordPress cache
- Check browser console for JavaScript errors
- Verify file permissions (folders: 755, files: 644)
Connection Status Shows Red
Problem: Dashboard shows "Disconnected" or red status
Solutions:
- Verify Next.js site is running and accessible
- Check that secrets match between WordPress and Next.js
- Test the revalidation endpoint manually:
curl -X POST http://your-nextjs-site.com/api/revalidate \
-H "Content-Type: application/json" \
-d '{"secret":"your-secret","paths":["/"]}' - Check WordPress can make outbound HTTP requests
- Verify no firewall blocking the connection
ACF Fields Not Showing
Problem: Page Builder and sidebar blocks don't appear
Solutions:
- Install and activate ACF Pro
- Deactivate and reactivate FlatWP plugin
- Check for PHP errors in WordPress debug log
- Verify FlatWP Companion plugin is fully activated
- Try creating a new page to see if fields appear
Content Not Updating on Next.js Site
Problem: Changes in WordPress don't appear on the website
Solutions:
- Check webhook is enabled in Settings
- Verify revalidation secret matches
- Check Activity Logs for webhook errors
- Test revalidation endpoint is working
- Try manually clearing cache from dashboard
- Check Next.js site logs for errors
Build Errors
Problem: npm run build fails with errors
Solutions:
# Clean install
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
npm run build
# Try specific Node version
nvm use 18
npm install
npm run build
Advanced Configuration
Custom Revalidation Paths
Add a filter to customize which paths get revalidated:
// In your theme's functions.php
add_filter('flatwp_revalidation_paths', function($paths, $post_id) {
// Add custom paths
$paths[] = '/custom-page';
$paths[] = '/another-page';
return $paths;
}, 10, 2);
Modify Preview Token Expiry
Change how long preview links stay active:
add_filter('flatwp_preview_token_expiry', function($expiry) {
return 7200; // 2 hours instead of default 1 hour
});
Custom Dashboard Branding
The React dashboard can be customized by modifying the source files in admin-react/src/ and rebuilding.
API Endpoints
The plugin provides REST API endpoints:
Health Check
GET /wp-json/flatwp-react/v1/dashboard/stats
Returns dashboard statistics.
Connection Status
GET /wp-json/flatwp-react/v1/connection/status
Checks Next.js connection.
Cache Stats
GET /wp-json/flatwp-react/v1/cache/stats
Returns cache information.
All endpoints require WordPress authentication (nonce).
Performance Tips
Production Optimization
-
Always use production build:
npm run build
# NOT npm run dev -
Enable WordPress object caching with Redis or Memcached
-
Use a CDN for static assets
-
Keep WordPress updated for security and performance
Development Tips
- Use
npm run devinadmin-react/for hot reload during development - Check browser console for React errors
- Use React DevTools extension for debugging
- Monitor Network tab for API calls
Updating the Plugin
When a new version is released:
- Download the latest release from GitHub
- Deactivate the current plugin
- Delete the old plugin folder
- Upload and activate the new version
- Run
npm install && npm run buildinadmin-react/ - Check that everything still works
Getting Help
Documentation
Community Support
- GitHub Discussions - Ask questions
- GitHub Issues - Report bugs
- FlatWP Website - Documentation and updates
Next Steps
Now that your plugin is set up:
- ACF Setup - Learn how to use the content blocks
- Customization - Customize your site
- Configuration - Advanced configuration options
- Deployment - Deploy to production
FAQ
Q: Do I need ACF Pro? A: ACF Pro is recommended for the full experience, but ACF Free works for basic functionality.
Q: Can I use my own custom fields? A: Yes! The plugin works with any ACF fields exposed via WPGraphQL.
Q: Will this work with my existing WordPress site? A: Yes, as long as you have WPGraphQL installed.
Q: Is the React dashboard required? A: No, but it provides a much better experience for managing the integration.
Q: Can I customize the dashboard? A: Yes, you can modify the React source code and rebuild.
Q: What happens if Next.js is down? A: WordPress continues to work normally. The plugin logs failed webhook attempts.