=== Headless Bridge by Crux === Contributors: andyryan Tags: headless, rest-api, jamstack, next.js, performance Requires at least: 5.8 Tested up to: 6.9 Stable tag: 1.0.4 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Zero-runtime headless API with pre-compiled JSON responses for fast content delivery. == Description == **Headless Bridge by Crux** is a high-performance headless solution that pre-compiles your content into optimized JSON responses. Unlike traditional approaches that calculate data on-the-fly, Headless Bridge compiles everything when you save a post, resulting in fast API responses. = Why Headless Bridge? = Traditional headless setups can suffer from runtime overhead: * They calculate data **on-the-fly**, leading to slow TTFB (Time To First Byte) * Complex, nested JSON structures that frontend developers struggle with * Every request hits the database and runs PHP logic * Performance degrades as your site grows **Headless Bridge uses a "Zero-Runtime" architecture:** * Pre-calculates the entire API response when a post is **SAVED** * Stores flat, optimized JSON in a custom database table * Serves responses via a single, fast REST endpoint * Includes SEO metadata and responsive images automatically = How It Works = Traditional headless setups calculate data on every request, running multiple database queries and PHP logic each time. Headless Bridge takes a different approach: * **Pre-compiles content** when you save a post, not when a visitor requests it * **Serves flat JSON** from a single optimized database query * **Reduces response size** with a streamlined, flat data structure * **Eliminates runtime overhead** by removing on-the-fly calculations = Free Features = * ✅ **Pre-compiled JSON** - Zero runtime overhead * ✅ **Flat JSON structure** - Intuitive for React/Next.js developers * ✅ **SEO ready** - Auto-includes Yoast/RankMath metadata * ✅ **Image optimization** - Srcset data for next/image * ✅ **Background processing** - Uses Action Scheduler or WP-Cron * ✅ **API key authentication** - Secure preview access * ✅ **Rate limiting** - Built-in DDoS protection * ✅ **UUID-based IDs** - Prevents ID enumeration attacks * ✅ **Multi-language** - WPML & Polylang support = Pro Features (Separate Plugin) = Upgrade to the Pro addon plugin for advanced functionality: * 🚀 **ACF Integration** - Automatically include Advanced Custom Fields in your API responses * 🚀 **Webhooks** - Trigger external services (Vercel, Netlify, etc.) on content updates * 🚀 **Priority Support** - Email support with 24-hour response time * 🚀 **Automatic Updates** - Seamless plugin updates through WordPress **Pro is a separate addon plugin** that extends the free version. [Learn more & Download Pro →](https://www.headless-bridge.com/pro) = Built For = * Next.js websites * React applications * Jamstack sites * Mobile apps * High-traffic headless WordPress sites = API Endpoints = **Base URL:** `https://your-wordpress-site.com/wp-json/bridge/v1` * `GET /page?slug={slug}` - Get page by slug * `GET /page/{uuid}` - Get page by UUID * `GET /pages?type={type}&limit=20` - List pages * `GET /stats` - Get cache statistics (admin only) = Developer Friendly = * Clean, flat JSON structure * TypeScript-ready responses * Comprehensive hooks and filters * Well-documented codebase * Built with security in mind == Installation == 1. Upload the plugin files to `/wp-content/plugins/headless-bridge`, or install through the WordPress plugins screen 2. Activate the plugin through the 'Plugins' screen 3. Go to **Headless Bridge → Dashboard** to verify installation 4. Click **"Recompile All Content"** to process existing posts 5. Use the API endpoints in your frontend application = Next.js Integration Example = ```javascript // lib/wordpress.ts const WP_API_URL = process.env.NEXT_PUBLIC_WP_API_URL; export async function getPage(slug) { const res = await fetch( `${WP_API_URL}/bridge/v1/page?slug=${slug}`, { next: { revalidate: 3600 } } ); return res.ok ? res.json() : null; } ``` == Frequently Asked Questions == = Can this replace other headless solutions? = For most standard content delivery use cases, yes. If you need complex nested queries, a GraphQL-based solution might be more suitable, but Headless Bridge excels at fast, pre-compiled content delivery. = How does it handle content updates? = Content is automatically recompiled in the background when you save a post. There's no manual cache invalidation needed. = Does it work with ACF (Advanced Custom Fields)? = Yes! ACF support is available in the **Pro addon plugin** (sold separately). The Pro addon extends this free plugin with ACF integration, webhooks, and more. [Get Pro addon →](https://www.headless-bridge.com/pro) = What about custom post types? = Yes! Enable them in **Settings → Enabled Post Types**. = How do I invalidate the cache? = The cache auto-updates when you save a post. For manual clearing: **Dashboard → Clear All Cache** = Can I use this with WPML/Polylang? = Yes! Multi-language support is **FREE** and works automatically with WPML and Polylang. See MULTILINGUAL.md for setup instructions. = How do I preview draft content? = Generate an API key in **Headless Bridge → API Keys**, then use it in your requests with the `preview=true` parameter. = Is it secure? = Yes! Built with security in mind: * API keys stored as SHA-256 hashes * Rate limiting to prevent DDoS * UUID-based IDs to prevent enumeration * Preview access requires authentication == Screenshots == 1. Dashboard with cache statistics and queue status 2. Settings page for configuration 3. API Keys management 4. License activation (Pro) 5. Example JSON response == Changelog == = 1.0.4 = * Version bump and rebuild for distribution = 1.0.3 = * Fix: Resolved fatal error from undefined constants (HEADBRIDGE_PLUGIN_URL, HEADBRIDGE_VERSION) in admin, license, and updater classes * Fix: Aligned all constant references to use HB_VERSION, HB_PLUGIN_URL, HB_PLUGIN_FILE = 1.0.2 = * Fix: WordPress.org compliance - Removed all license validation code from free version * Fix: WordPress.org compliance - Changed all prefixes from "hb" to "headbridge" (4+ character requirement) * Enhancement: All features now fully functional in free version with zero restrictions * Info: Pro features (ACF, Webhooks, Auto-updates) available as separate addon plugin = 1.0.1 = * Fix: Added locale fallback for post queries to ensure posts appear in API * Fix: Improved database query handling for multi-locale environments * Enhancement: Better error handling when posts have strict locale matching = 1.0.0 = * Initial release * Core API endpoints (/page, /pages, /stats) * SEO metadata support (Yoast, RankMath) * Image optimization with srcset * Background compilation with Action Scheduler * API key authentication * Rate limiting * UUID-based public IDs * Multi-language support (WPML/Polylang) * License validation system * Pro features: ACF integration, Webhooks * Auto-update mechanism for Pro users == Upgrade Notice == = 1.0.0 = Initial release of Headless Bridge - zero-runtime headless API with pre-compiled responses. == Support == For support, please visit: * [Documentation](https://www.headless-bridge.com/docs) * [GitHub Issues](https://github.com/cruxadvisors/headless-bridge-by-crux/issues) **Pro users:** Priority email support included with your license.