Implements a proof-of-concept for caplet UIs running in sandboxed iframes
with Preact. Demonstrates:
- Host-managed caplet backends with state and method handlers
- postMessage-based communication protocol with capletId routing
- Nested widget iframes (Slot component) for widget composition
- State subscription pattern for reactive UI updates
All caplets/widgets communicate directly with window.top, enabling
arbitrary nesting depth while maintaining simple message routing.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Proof-of-concept prototype for caplet UIs running in sandboxed iframes with Preact. This explores an architecture where:
capletIdpostMessagetowindow.top<Slot>component, each with their own backendKey components:
CapletManager- Host-side message router for multiple caplets/widgetsCapletBridge- Iframe-side communication bridgeSlot- Component for embedding nested widget iframesuseBackendState,useBackendMethods) - React-style state subscriptionTo try it:
Security notes (prototype limitations):
allow-same-originsandbox attribute (required for Vite dev server)*forpostMessageoriginThese would need to be addressed for production (cross-origin serving, explicit origins, etc.)
Test plan
🤖 Generated with Claude Code