Sandbox & Security
Widgets run in a controlled environment that prevents interference with other widgets and protects the host overlay.Network Isolation
Widgets cannot make directfetch or XMLHttpRequest calls. All HTTP traffic goes through the backend proxy:
Timer Management
RawsetTimeout and setInterval are available but not tracked. Use SBCanvas.setTimeout and SBCanvas.setInterval instead — they’re automatically cancelled when the widget unloads:
Storage Isolation
SBCanvas.store is namespaced per widget. One widget cannot read or write another widget’s store data:
Cross-Widget Communication
Widgets communicate through named channels only:Input Sanitization
Always sanitize user-generated content before rendering:| Method | Use For |
|---|---|
sanitize.html(str) | Escaping HTML entities |
sanitize.js(str) | Escaping for JS string context |
sanitize.url(str) | Escaping URLs |
sanitize.attr(str) | Escaping HTML attribute values |
Best Practices
- Use
SBCanvas.httpfor all network requests - Use
SBCanvas.setTimeout/setIntervalfor automatic cleanup - Use
textContentfor user-generated text (never rawinnerHTML) - Use
SBCanvas.storefor persistence (notlocalStoragedirectly) - Keep event handlers fast — the overlay runs at 60fps
- Clean up DOM elements you create dynamically