VibeFrame
VibeFrame renders AI-generated React components in a sandboxed iframe. It handles code compilation, data passing, auto-resizing, and error handling—all while maintaining strict security isolation.Basic Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | - | React component code to render |
id | string | - | Component ID (for saved components) |
data | Record<string, unknown> | {} | Data passed to the component as props |
rendererUrl | string | /api/vibe/render | Base URL for the render endpoint |
className | string | - | CSS class for the container |
minHeight | number | 100 | Minimum iframe height in pixels |
maxHeight | number | 600 | Maximum iframe height in pixels |
onRender | () => void | - | Called when component renders successfully |
onError | (error: string) => void | - | Called when rendering fails |
loadingFallback | ReactNode | - | Custom loading UI |
errorFallback | ReactNode | ((error: string) => ReactNode) | - | Custom error UI |
How It Works
1. Code Compilation
When you providecode, VibeFrame generates a data URL containing:
- React 18 (loaded from CDN)
- Babel standalone (for JSX compilation)
- Tailwind CSS (loaded from CDN)
- Your component code
2. PostMessage Bridge
The iframe and parent communicate via PostMessage:3. Auto-Resize
The iframe automatically resizes based on content:minHeight and maxHeight.
Security Model
Sandbox Restrictions
- ✅ Allows JavaScript execution
- ❌ Blocks same-origin access (can’t read parent DOM)
- ❌ Blocks form submission
- ❌ Blocks popups and new windows
- ❌ Blocks top-level navigation
- ❌ Blocks plugins