# DreamStack Integration Guide Embed DreamStack apps into any website with the standalone SDK (~3KB). ## Quick Start ### 1. Iframe Embed ```html ``` ### 2. Web Component ```html ``` ### 3. JavaScript API ```html
``` ## Framework Examples ### React ```jsx import { useEffect, useRef } from 'react'; function DreamStackEmbed({ src }) { const ref = useRef(null); useEffect(() => { const handle = DreamStack.connect(src, ref.current); return () => handle.destroy(); }, [src]); return
; } ``` ### Vue ```vue ``` ## Build Flags ```bash # Standard build dreamstack build app.ds # Minified (strips whitespace, ~17% smaller) dreamstack build app.ds --minify # Both optimizations are always active: # - DOM helpers (shorthand functions, ~3KB saved) # - Tree-shaking (unused runtime features stripped, ~40-50% saved) ``` ## Signal Bridge Protocol DreamStack apps communicate via `postMessage`: ```js // Send to DreamStack app iframe.contentWindow.postMessage({ type: 'ds:signal', name: 'playerName', value: 'Alice' }, '*'); // Receive from DreamStack app window.addEventListener('message', (e) => { if (e.data?.type === 'ds:signal') { console.log(e.data.name, '=', e.data.value); } }); ``` ## Size Budget | Build Mode | Size | Reduction | |---|---|---| | Default | ~95 KB | baseline | | DOM helpers (auto) | ~95 KB | -3% | | Tree-shaken (auto) | ~52 KB | -46% | | + Minified | ~44 KB | -54% | | Gzipped | ~8 KB | ~92% |