WordPress 7.0 Adds WebSocket Real-Time Collaboration Features
WordPress 7.0 has introduced collaborative block editing capabilities powered by Yjs CRDT technology. The platform now supports real-time collaboration features that fundamentally change how multiple users can work together on WordPress content.
The default implementation uses HTTP polling for data synchronization. However, the platform includes a sync.providers filter in its RTC layer. This filter allows developers to implement custom transport mechanisms, opening the door for more efficient communication methods.
WebSocket-Based Solution Expands WordPress Capabilities
A developer has created a WebSocket-based Yjs sync provider that replaces the standard HTTP polling approach. This implementation revealed broader possibilities for real-time functionality in WordPress beyond just collaborative editing.
The WebSocket integration enables any add_action hook to push real-time CustomEvent notifications to connected browsers. This happens without requiring polling or a custom server setup. Therefore, developers can now build truly real-time features within the WordPress ecosystem.
Technical Architecture and Security
The solution uses a Rust-based relay server built with Axum and Tokio frameworks. The relay server prioritizes WebSocket connections while providing Server-Sent Events (SSE) as a fallback option. This dual approach ensures broader compatibility across different environments.
Security measures include multiple layers of protection. Event payloads receive AES-256-GCM encryption before leaving WordPress, ensuring the relay server only handles ciphertext. Publishing authentication uses HMAC-SHA256 signed requests to verify legitimate sources.
Browser connections operate on short-lived scoped JSON Web Tokens (JWTs) that expire after five minutes. These tokens automatically refresh, maintaining secure connections without requiring manual intervention. The WordPress plugin is available as open source under GPL-2.0 licensing.
Real-World Applications
Several practical use cases have emerged from early adopters. WooCommerce stores can now display live order updates without page refreshes. Additionally, news sites can push breaking news flags to readers in real time.
Real-time comment counts provide immediate feedback on content engagement. The collaborative editing features in WordPress 7.0 RTC benefit directly from the improved transport mechanism. These examples demonstrate how WebSocket integration enhances user experience across different WordPress applications.
Implementation Details
The project, called WPSignal, is available on GitHub at github.com/wpsignal/wordsocket. The implementation provides a hosted relay option for users who prefer not to manage their own infrastructure. However, the open-source nature allows self-hosting for those requiring full control.
The real-time event bus wired into WordPress action hooks creates new possibilities for plugin developers. This architecture allows developers to build features that previously required complex custom solutions or third-party services. Consequently, WordPress sites can deliver more dynamic, interactive experiences without significant infrastructure changes.
Future Possibilities
The developer community is exploring additional applications for this real-time capability. The event bus architecture suggests numerous potential use cases beyond the currently documented examples. From live form submissions to instant notification systems, the possibilities extend across the WordPress ecosystem.
This advancement represents a significant shift in WordPress’s real-time capabilities. The combination of collaborative editing in WordPress 7.0 and flexible WebSocket transport opens new avenues for interactive web applications. As developers experiment with these features, more innovative implementations will likely emerge.
Original Source: wpsignal.io