Skip to main content

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

How It Works

1. Code Compilation

When you provide code, 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:
VibeFrame constrains this between minHeight and maxHeight.

Security Model

Sandbox Restrictions

This sandbox policy:
  • ✅ 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

Code Validation

Before rendering, code is validated for dangerous patterns:

Rendering Modes

Direct Code Rendering

Pass code directly for previews:

Saved Component Rendering

Pass an ID to render saved components:
This fetches the component from your render endpoint.

Custom Loading States

Event Handling

Data Updates

Data is automatically sent when it changes:

API Endpoint Setup

For saved components, create a render endpoint:

Best Practices

1. Always Set Max Height

Prevent malicious components from expanding infinitely:

2. Validate Data Before Passing

Don’t pass sensitive data to generated components:

3. Handle Errors Gracefully

Always provide error handling:

4. Use Loading States

Show users something while compiling: