embed_url that renders the full Theo-branded browser chrome (URL bar, live indicator, auto-reconnect UI) in a third-party iframe. No SDK wiring, no manual CDP handling — point an <iframe> at the URL and ship.
Quick start
- Create a session from your backend (never expose your
THEO_API_KEYto the browser):
- Drop the URL into an iframe on your frontend:
- Fetching the correct live view URL on first paint (no
about:blankflash) - Listening for
browserbase-disconnectedpostMessages - Auto-refetching and rekeying the iframe when the CDP target changes
- Tight 10 s polling while disconnected, relaxed 30 s while healthy
- A Theo-branded URL bar + live indicator + reconnect overlay
How the token works
embed_url is a signed, short-lived URL bound to (sessionId, userId):
- Format:
{APP_ORIGIN}/embed/browser/{sessionId}?token=<hmac> - Scope: the token is tied to a specific session AND the user who created it
- Lifetime: 60 minutes (Theo Browser sessions hard-cap at 20 min, so this leaves headroom for
keep_alivesessions) - Secret: signed with
BROWSER_EMBED_TOKEN_SECRETon the server; never exposed to the client - Rotation: every
GET /api/v1/browser/sessions/:idcall mints a fresh token, so long-running dashboards can refresh the iframe on demand
Disconnect handling
The embed page already implements the full recovery protocol, but if you’re building a custom iframe wrapper, here is the exact contract:live_view_version counter every time it resolves a fresh debugger URL — the iframe rekeys on version change, not URL equality, because BrowserBase can return the same URL string while silently swapping the underlying CDP page target.
Security posture
- Iframe sandbox:
allow-scripts allow-same-originis the minimal set that keeps the DevTools frontend + CDP WebSocket alive. Addingallow-forms/allow-popupshas no functional benefit and can trigger stray navigations that retarget the iframe out of the live view. frame-ancestors *: the embed page setsContent-Security-Policy: frame-ancestors *so any origin can iframe it. If you want to restrict which origins can load the embed, terminate the iframe at your own CDN layer and apply your own header.- No credentials in the iframe: the embed page never sees your API key. It talks to a companion token-authenticated
/embed/browser/:id/liveroute.
End the session
Always end the session from your backend when the user closes the iframe, otherwise you’re billed for the remaining wall-clock time:Related
- Browser Sessions API — the full
/api/v1/browser/sessionssurface - Theo Browser SDK — typed helpers for Node/Deno/edge
